diff options
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/statusbar/batinfo | 33 | ||||
| -rwxr-xr-x | .local/bin/statusbar/checkupdates | 15 | ||||
| -rwxr-xr-x | .local/bin/statusbar/cpuinfo | 30 | ||||
| -rwxr-xr-x | .local/bin/statusbar/meminfo | 13 | ||||
| -rwxr-xr-x | .local/bin/statusbar/netinfo | 34 | ||||
| -rwxr-xr-x | .local/bin/statusbar/timeinfo | 15 | ||||
| -rwxr-xr-x | .local/bin/statusbar/volinfo | 13 |
7 files changed, 153 insertions, 0 deletions
diff --git a/.local/bin/statusbar/batinfo b/.local/bin/statusbar/batinfo new file mode 100755 index 0000000..1719181 --- /dev/null +++ b/.local/bin/statusbar/batinfo @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +set -e + +status="$(acpi -abi)" # get battery and adapter info + +case $BLOCK_BUTTON in + 1) notify-send -t $((15 * 1000)) --urgency=low "Battery status" "$status" ;; + 4) brightnessctl -q s 10%+ ;; + 5) brightnessctl -q s 10%- ;; +esac + +power=$(echo "${status}" | awk '/Battery [0-9]+: [A-Z]/{s+=$4;c++}; END{printf "%.1f%%", s/c}') + +icon='?' +if [[ -z $(echo $status | sed -n '/on-line/p') ]]; then + case "${power%.*}" in + 100 | 9[0-9]) icon='\uf578' ;; + 8[0-9]) icon='\uf581';; + 7[0-9]) icon='\uf580';; + 6[0-9]) icon='\uf57f';; + 5[0-9]) icon='\uf57e';; + 4[0-9]) icon='\uf57d';; + 3[0-9]) icon='\uf57c';; + 2[0-9]) icon='\uf57b';; + 1[0-9]) icon='\uf57a';; + [0-9]) icon='\uf579';; + esac +else + icon='\uf583' +fi + +echo -e "$icon $power" diff --git a/.local/bin/statusbar/checkupdates b/.local/bin/statusbar/checkupdates new file mode 100755 index 0000000..5a95974 --- /dev/null +++ b/.local/bin/statusbar/checkupdates @@ -0,0 +1,15 @@ +#!/usr/bin/env sh +set -e + +updates=$(pacman -Qu | sed '/\[ignored\]$/d') + +case $BLOCK_BUTTON in + 1) ;& # fallthrough + 3) if [ -n "${updates}" ]; then + notify-send -t $((1000 * 20)) "Available updates" "$updates" + else + notify-send "Available updates" "No available updates" + fi;; +esac + +[ -n "$updates" ] && echo $(echo "${updates}" | wc -l) || exit 0 diff --git a/.local/bin/statusbar/cpuinfo b/.local/bin/statusbar/cpuinfo new file mode 100755 index 0000000..f46121b --- /dev/null +++ b/.local/bin/statusbar/cpuinfo @@ -0,0 +1,30 @@ +#!/usr/bin/env sh +set -e + +case $BLOCK_BUTTON in + 1) notify-send --urgency=low \ + "Process status" \ + "$(ps -eo pid,pcpu,size,comm \ + | sort -rnk 3 \ + | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3; + $1="";$2="";$3=""; + print $0; c++} + c>10 {exit}')" + ;; + 3) notify-send --urgency=low \ + "Process status" \ + "$(ps -eo pid,pcpu,size,cmd \ + | sort -rnk 3 \ + | cut -b -45 \ + | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3; + $1="";$2="";$3=""; + print $0; c++} + c>10 {exit}')" + ;; +esac + +# Load +sed -Ee 's/^([0-9]+\.[0-9]+) .*/[\1 /g' /proc/loadavg | tr -d '\n' + +# Thermals +awk '{s+=$1}END{printf "%.1f°]", s / (1000*NR)}' /sys/class/thermal/thermal_zone*/temp diff --git a/.local/bin/statusbar/meminfo b/.local/bin/statusbar/meminfo new file mode 100755 index 0000000..2b31b97 --- /dev/null +++ b/.local/bin/statusbar/meminfo @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +set -e + +case $BLOCK_BUTTON in + 1) notify-send --urgency=low \ + "Memory status" \ + "$(free -h | \ + awk '/total/ {printf "%15s%10s%10s\n", $1, $2, $3} + /Mem|Swap/{printf "%-5s%10s%10s%10s\n", $1, $2, $3, $4}')" + ;; +esac + +free -h | awk '/Mem/{print "[" $3 " RAM " $2 "]" }' diff --git a/.local/bin/statusbar/netinfo b/.local/bin/statusbar/netinfo new file mode 100755 index 0000000..d59ef05 --- /dev/null +++ b/.local/bin/statusbar/netinfo @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +netstatus="$(awk '{ + n = split(FILENAME, a, "/") + printf("%-15s %s\n", a[n-1], $1) + }' /sys/class/net/[ew]*/operstate | sort -k 2)" + +function add_connected_address() { + TMPIFS=$IFS + IFS=' +' + for line in $netstatus; do + device=$(echo $line | awk '{print $1}') + address=$(ip addr show $device | sed -En 's/inet ([0-9\.]+).*/\1/p') + # Append Wifi AP if connected + [ -n "$address" ] && address=$address" ("$(iwgetid -r)")" + echo $line $address + done + IFS=$TMPIFS +} + +ARG=${1:-$BLOCK_BUTTON} + +case $ARG in + 1) notify-send --urgency=low "Internet connection" "$(add_connected_address)" ;; +esac + +if [ -z "$(echo -e "${netstatus}" | sed -En '/up$/p' | tr -d '\n')" ]; then + echo -en '\x0c' +else + echo -n "${netstatus}" | sed -En 's/^(w[^ ]+).*up//p;s/^(e[^ ]+).*up/\x0d/p' +fi + +echo -en '\x0b' diff --git a/.local/bin/statusbar/timeinfo b/.local/bin/statusbar/timeinfo new file mode 100755 index 0000000..a091f84 --- /dev/null +++ b/.local/bin/statusbar/timeinfo @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +ARG=${1:-$BLOCK_BUTTON} + +case $ARG in + 1) notify-send --urgency=low \ + "Calendar" \ + "$(cal -w -m)" + ;; + 3) notify-send --urgency=low \ + "Weather" \ + "$(weather)" + ;; + esac +date +'%F %R' diff --git a/.local/bin/statusbar/volinfo b/.local/bin/statusbar/volinfo new file mode 100755 index 0000000..fd09b13 --- /dev/null +++ b/.local/bin/statusbar/volinfo @@ -0,0 +1,13 @@ +#!/usr/bin/env sh + +ARG=${1:-$BLOCK_BUTTON} + +case $ARG in + 1) pamixer -t && sigdwmblocks 4;; + 4) pamixer -i 1 && sigdwmblocks 4;; + 5) pamixer -d 1 && sigdwmblocks 4;; +esac + +VOL=$(pamixer --get-volume) + +pamixer --get-mute >/dev/null && echo -ne "\x0c\ufa80${VOL}\x0b" || echo -ne "\ufa7d${VOL}" |
