diff --git a/scripts/bar.sh b/scripts/bar.sh new file mode 100755 index 0000000..1a71221 --- /dev/null +++ b/scripts/bar.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +icon_color="#A0A57E" +icon() { echo -n "%{F$icon_color}"; printf '%b' "\ue$1"; echo -n "%{F-}"; } + +icon_music=$(icon 05c) +icon_music_paused=$(icon 059) +icon_services=$(icon 040) +icon_diskspace=$(icon 0ab) +icon_wifi=$(icon 048) +icon_battery=$(icon 033) +icon_battery_charging=$(icon 042) +icon_clock=$(icon 018) + +color_service_running="#A0A57E" +color_service_stopped="#C37561" +color_battery_good="white" +color_battery_low="#C37561" + +music() { + info=$(mpc current -f '[%artist%] - [%title%]') + icon=$icon_music + if [ -z "$info" ]; then + info="(-)" + elif [ -n "$(mpc status | grep paused)" ]; then + icon=$icon_music_paused + fi + echo -n "$icon $info" +} + +serviceinfo() { + service=$1 + text=$2 + systemctl is-active -q $service + if [ "$?" -eq 0 ]; then + echo -n "%{F$color_service_running}$text%{F-}" + else + echo -n "%{F$color_service_stopped}$text%{F-}" + fi +} + +services() { + echo -n "$icon_services $(serviceinfo zomnet z) $(serviceinfo docker d)" +} + +diskspace() { + echo -n "$icon_diskspace " + df -h | awk '{if($6 == "/") { print $3 " / " $2 }}' +} + +wifi() { + echo -n "$icon_wifi " + info=$(wicd-cli --wireless --status | perl -e 'foreach $line (<>) { if($line =~ /Connected to (.+) at .+IP: ([0-9.]+)/ ) { print $1 . " - " . $2; break; } elsif($line =~ /Connecting to wireless network \"(.+)\"/) { print $1 . " - connecting"; break; } }') + if [ -z "$info" ]; then + info="(-)" + fi + echo -n $info +} + +battery() { + level=$(acpi -b | awk -F, 'BEGIN { s=0 } { s+=$2 } END { print int(s/NR) }') + charging=$(acpi -b | grep Charging) + if [ -n "$charging" ]; then + echo -n "$icon_battery_charging " + else + echo -n "$icon_battery " + fi + + if [ "$level" -lt 20 ]; then + echo -n "%{F$color_battery_low}$level%%{F-}" + else + echo -n "%{F$color_battery_good}$level%%{F-}" + fi +} + +clock() { + echo -n "$icon_clock " + date +"%a %d.%m (%V) %H:%M" +} + +while true; do + echo "%{l} $(music) $(services) $(diskspace)%{r}$(wifi) $(battery) $(clock) " + sleep 1 +done | lemonbar -g 1366x15 -f "Terminus:size=8","Stlarch:size=6:style=regular" -B "#88000000" + + diff --git a/scripts/batteryobserver.sh b/scripts/batteryobserver.sh new file mode 100755 index 0000000..8c8e13d --- /dev/null +++ b/scripts/batteryobserver.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +#Config +WARNING_LEVEL=10 +SHUTDOWN_LEVEL=2 +#End config + + +STATE=0 + +while true; do + level=$(acpi -b | awk -F, 'BEGIN{s=0}{s+=$2}END{print int(s/NR)}') + charger_connected=$(acpi -b | grep Charging) + case "$STATE" in + 0) # battery ok + if [ "$level" -le "$WARNING_LEVEL" -a -z "$charger_connected" ]; then + zenity --warning --text="Your battery is getting low\!" --no-wrap & + STATE=1 + fi + ;; + 1) # battery low + if [ -n "$charger_connected" ]; then + STATE=0 + elif [ "$level" -le "$SHUTDOWN_LEVEL" ]; then + systemctl hibernate; + else + notify-send -u critical -a "BatterySystem" "Battery is low!" "Please connect a charger" + fi + ;; + esac + sleep 20 +done + diff --git a/scripts/blurlock.sh b/scripts/blurlock.sh new file mode 100755 index 0000000..b075129 --- /dev/null +++ b/scripts/blurlock.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +TMP=/tmp/lockscreen.png + +#scrot -q 30 -z $TMP +#convert $TMP -scale 10% -scale 1000% $TMP + +blurscreen $TMP +exec i3lock -u -i $TMP diff --git a/scripts/cmenu.sh b/scripts/cmenu.sh new file mode 100755 index 0000000..89d2a2f --- /dev/null +++ b/scripts/cmenu.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +DMENU="$(dirname $0)/dmenu.sh" +menu() { + echo $@ | tr ' ' '\n' | $DMENU +} + +screenshot() { + cd ~/Screenshots + exec scrot $@ -e 'firefox $f' +} + +sysctl() { + action=$1 + service=$2 + gksu -S -m "$action $service" systemctl $action $service +} + +require-service() { + service=$1 + systemctl is-active --quiet $service || sysctl start $service +} + +case "$(menu timer screenshot wallpaper wicd ncmpcpp zomnet power)" in + timer) + exec urxvt -geometry 50x3 -e ~/.config/scripts/teatimer.sh + ;; + screenshot) + case "$(menu all selective)" in + all) + screenshot + ;; + selective) + screenshot -s + ;; + esac + ;; + wallpaper) + exec nitrogen ~/wallpapers + ;; + wicd) + exec wicd-gtk + ;; + ncmpcpp) + exec urxvt -e ncmpcpp + ;; + zomnet) + case "$(menu start-stop uservm ncmpcpp deluge)" in + start-stop) + systemctl is-active zomnet > /dev/null + if [ "$?" -eq 0 ]; then + sysctl stop zomnet + else + sysctl start zomnet + fi + ;; + uservm) + require-service zomnet + exec urxvt -e ssh user.vm.zom.bi + ;; + ncmpcpp) + require-service zomnet + exec urxvt -e ncmpcpp -h user.vm.zom.bi + ;; + deluge) + require-service zomnet + exec deluge-gtk + esac + ;; + power) + case "$(menu hibernate suspend reboot poweroff)" in + hibernate) + systemctl hibernate + ;; + suspend) + systemctl suspend + ;; + reboot) + systemctl reboot + ;; + poweroff) + systemctl poweroff + ;; + esac + ;; +esac + diff --git a/scripts/dmenu.sh b/scripts/dmenu.sh new file mode 100755 index 0000000..d67b16a --- /dev/null +++ b/scripts/dmenu.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exec dmenu -ch -y 100 -w 600 -h 30 -l 10 -sb "#444444" $@ diff --git a/scripts/dmenu_run.sh b/scripts/dmenu_run.sh new file mode 100755 index 0000000..743c068 --- /dev/null +++ b/scripts/dmenu_run.sh @@ -0,0 +1,15 @@ +#!/bin/sh +cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"} +if [ -d "$cachedir" ]; then + cache=$cachedir/dmenu_run +else + cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~ +fi +( + IFS=: + if stest -dqr -n "$cache" $PATH; then + stest -flx $PATH | sort -u | tee "$cache" | $(dirname $0)/dmenu.sh + else + $(dirname $0)/dmenu.sh < "$cache" + fi +) | ${SHELL:-"/bin/sh"} & diff --git a/scripts/explorer_run.sh b/scripts/explorer_run.sh new file mode 100755 index 0000000..4403d0b --- /dev/null +++ b/scripts/explorer_run.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +DMENU=$(dirname $0)/dmenu.sh + +UP="[..]" +OPEN_EXPLORER="[Open Thunar here]" +OPEN_TERMINAL="[Open Terminal here]" +WIDTH=300 +LINES=30 + +OPEN_CMD="xdg-open" +TERM_CMD="urxvt" + +if [ -n "$1" ]; then + DIR=$1 +else + DIR=$HOME +fi + +while true; do + bname=$(basename "$DIR") + choice=$( + ( + echo "$UP"; + echo "$OPEN_EXPLORER"; + echo "$OPEN_TERMINAL"; + ls $DIR; + ) | $DMENU -i + ) + if [ -z "$choice" ]; then + exit 1 + elif [ "$choice" == "$UP" ]; then + DIR=$(dirname $DIR) + elif [ "$choice" == "$OPEN_EXPLORER" ]; then + ($OPEN_CMD "$DIR" &) & + exit 0 + elif [ "$choice" == "$OPEN_TERMINAL" ]; then + ( cd $DIR; $TERM_CMD &) & + exit 0 + elif [ -f "$DIR/$choice" ]; then + ($OPEN_CMD "$DIR/$choice" &) & + exit 0 + elif [ -d "$DIR/$choice" ]; then + DIR=$DIR/$choice + fi +done diff --git a/scripts/lock.sh b/scripts/lock.sh new file mode 100755 index 0000000..d082657 --- /dev/null +++ b/scripts/lock.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +mpc pause > /dev/null + +exec $(dirname $0)/blurlock.sh diff --git a/scripts/mirrorlist b/scripts/mirrorlist new file mode 100755 index 0000000..7c4c52e --- /dev/null +++ b/scripts/mirrorlist @@ -0,0 +1,15 @@ +#!/usr/bin/awk -f + +BEGIN { + c = "" +} + +/^##/ { + c = substr($0,4); +} + +/^#Server/ { + if( c==COUNTRY ) { + print substr($0,2); + } +} diff --git a/scripts/monitor_switch.sh b/scripts/monitor_switch.sh new file mode 100755 index 0000000..d3bec85 --- /dev/null +++ b/scripts/monitor_switch.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd $(dirname $0) + +./prepare_monitors.sh +nitrogen --restore & +~/.config/bspwm/bspwmrc diff --git a/scripts/pacrank b/scripts/pacrank new file mode 100755 index 0000000..22300d6 --- /dev/null +++ b/scripts/pacrank @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "$0 " + exit 1 +fi + +country=$1 + +INPUT=/etc/pacman.d/mirrorlist.pacnew +OUTPUT=/etc/pacman.d/mirrorlist + +cat $INPUT | awk -v "COUNTRY=$country" 'BEGIN { c="" } /^##/ { c=substr($0,4); } /^#Server/ { if(c==COUNTRY) { print substr($0,2); } }' | rankmirrors - | sudo tee $OUTPUT + diff --git a/scripts/prepare_monitors.sh b/scripts/prepare_monitors.sh new file mode 100755 index 0000000..adae0ab --- /dev/null +++ b/scripts/prepare_monitors.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +INTERN="LVDS1" +EXTERN="VGA1" + +xrandr --output $INTERN --auto + +if [ -n "$(xrandr -q | grep $EXTERN' connected')" ]; then + xrandr --output $EXTERN --auto --right-of $INTERN +else + xrandr --output $EXTERN --off +fi diff --git a/scripts/tabletmode.sh b/scripts/tabletmode.sh new file mode 100755 index 0000000..b6224ab --- /dev/null +++ b/scripts/tabletmode.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cd $(dirname $0) + +INTERN="LVDS1" +IDS=$(./wacomdevices.sh) + +if [ "$1" == "on" ]; then + #xrandr --output $INTERN --rotate left + xrandr --output $INTERN --rotate inverted + + for i in $IDS; do xsetwacom set $i Rotate half; done +else + #xrandr --output $INTERN --rotate left + xrandr --output $INTERN --rotate normal + + for i in $IDS; do xsetwacom set $i Rotate none; done +fi diff --git a/scripts/teatimer.sh b/scripts/teatimer.sh new file mode 100755 index 0000000..8ad7d06 --- /dev/null +++ b/scripts/teatimer.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo +echo -n " Time: " +read ttime + +python ~/Projects/teatimer-curses/main.py $ttime + +aplay ~/.config/assets/atone.wav > /dev/null diff --git a/scripts/volume.sh b/scripts/volume.sh new file mode 100755 index 0000000..add989a --- /dev/null +++ b/scripts/volume.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +case $1 in + +) + pamixer --unmute --increase 2 + ;; + -) + pamixer --unmute --decrease 2 + ;; + mute) + pamixer --toggle-mute + ;; + *) + exit 1 + ;; +esac + +MUTE=$(pamixer --get-mute) +if [ "$MUTE" == "true" ]; then + VOLUME=0 +else + VOLUME=$(pamixer --get-volume) +fi + +osd_cat --colour=White --shadow 1 --pos bottom --align center --offset 80 --delay=1 -b percentage -P $VOLUME -T "Lautstärke" diff --git a/scripts/wacomdevices.sh b/scripts/wacomdevices.sh new file mode 100755 index 0000000..5737428 --- /dev/null +++ b/scripts/wacomdevices.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +xsetwacom list dev | awk -F'\t' '{print $2}' | cut -c 5-