From 6f12f5169948871b6fcf7ded895d16ceb7cb9689 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Tue, 16 Aug 2022 00:01:38 +0200 Subject: [PATCH] initial prep for new DWM --- .local/bin/statusbar/sb-clock | 28 +--------------------------- .local/bin/statusbar/sb-forecast | 28 +++------------------------- .local/bin/statusbar/sb-help-icon | 17 ----------------- .local/bin/statusbar/sb-mpdup | 2 +- .local/bin/statusbar/sb-music | 19 ++----------------- .local/bin/statusbar/sb-volume | 15 ++------------- 6 files changed, 9 insertions(+), 100 deletions(-) delete mode 100755 .local/bin/statusbar/sb-help-icon diff --git a/.local/bin/statusbar/sb-clock b/.local/bin/statusbar/sb-clock index a3a602e2..b844adf0 100755 --- a/.local/bin/statusbar/sb-clock +++ b/.local/bin/statusbar/sb-clock @@ -1,29 +1,3 @@ #!/bin/sh -clock=$(date '+%I') - -case "$clock" in - "00") icon="" ;; - "01") icon="" ;; - "02") icon="" ;; - "03") icon="" ;; - "04") icon="" ;; - "05") icon="" ;; - "06") icon="" ;; - "07") icon="" ;; - "08") icon="" ;; - "09") icon="" ;; - "10") icon="" ;; - "11") icon="" ;; - "12") icon="" ;; -esac - -case $BLOCK_BUTTON in - 1) notify-send "This Month" "$(cal --color=always | sed "s/..7m//;s/..27m/<\/span><\/b>/")" && notify-send "Appointments" "$(calcurse -d3)" ;; - 2) setsid -f "$TERMINAL" -e calcurse ;; - 3) notify-send " Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\` -- Middle click opens calcurse if installed" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -echo " $(date "+%d.%m.%Y $icon %H:%M") " +date "+%d.%m.%Y %H:%M" diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast index 6fbc9bea..48e37134 100755 --- a/.local/bin/statusbar/sb-forecast +++ b/.local/bin/statusbar/sb-forecast @@ -1,11 +1,4 @@ #!/bin/sh - -# Usually intended for the statusbar. - -# If we have internet, get a weather report from wttr.in and store it locally. -# You could set up a shell alias to view the full file in a pager in the -# terminal if desired. This function will only be run once a day when needed. -# Options can be found at https://wttr.in/:help weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" weatheremoji="${XDG_CACHE_HOME:-$HOME/.cache}/weatheremoji" url="wttr.in/Karlsruhe" @@ -26,28 +19,13 @@ s/🌩// s/🌫// ' "${weatheremoji}" } -getforecast() { curl -sf "$url$opt" > "$weatherreport" && curl -sf "$url$emojiopt" > "$weatheremoji" || exit 1 ;} -# Some very particular and terse stream manipulation. We get the maximum -# precipitation chance and the daily high and low from the downloaded file and -# display them with coresponding emojis. +getforecast() { curl -sf "$url$opt" > "$weatherreport" && curl -sf "$url$emojiopt" > "$weatheremoji" ;} showweather() { emoji=$(cat "$weatheremoji") && printf "%s" "$(sed '16q;d' "$weatherreport" | grep -wo "[0-9]*%" | sort -rn | sed "s/^/ $(printf %.1s "$emoji") /g;1q" | tr -d '\n')" -sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print "  " $1 "°"," " $2 "°"}' ;} + sed '13q;d' "$weatherreport" | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/+//g' | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " " $1 "°"," " $2 "°"}' ;} -case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -e less -Srf "$weatherreport" ;; - 2) getforecast && showweather ;; - 3) notify-send " Weather module" "\- Left click for full forecast. -- Middle click to update forecast. -${emoji}: Chance of rain/snow -: Daily low -: Daily high" ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -# The test if our forcecast is updated to the day. If it isn't download a new -# weather report from wttr.in with the above function. [ "$(stat -c %y "$weatherreport" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] || getforecast && convertemoji + showweather diff --git a/.local/bin/statusbar/sb-help-icon b/.local/bin/statusbar/sb-help-icon deleted file mode 100755 index bc1a1405..00000000 --- a/.local/bin/statusbar/sb-help-icon +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# The clickable help menu. Middle click to restart wm. - -# If dwm is running, use dwm's readme and restart. -pidof dwm >/dev/null && - READMEFILE=/usr/local/share/dwm/larbs.mom - restartwm() { pkill -HUP dwm ;} || - restartwm() { i3 restart ;} - -case $BLOCK_BUTTON in - 1) groff -mom "${READMEFILE:-${XDG_DATA_HOME:-$HOME/.local/share}/larbs/readme.mom}" -Tpdf | zathura - ;; - 2) restartwm ;; - 3) notify-send " Help module" "\- Left click to open LARBS guide. -- Middle click to refresh window manager." ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac; echo "" diff --git a/.local/bin/statusbar/sb-mpdup b/.local/bin/statusbar/sb-mpdup index af81a7d6..60e9b799 100755 --- a/.local/bin/statusbar/sb-mpdup +++ b/.local/bin/statusbar/sb-mpdup @@ -4,5 +4,5 @@ # music player's status. mpd must be running on X's start for this to work. while : ; do - mpc idle >/dev/null && kill -45 "$(pidof "${STATUSBAR:-dwmblocks}")" || break + mpc idle >/dev/null && kill -46 "$(pidof dwm)" || break done diff --git a/.local/bin/statusbar/sb-music b/.local/bin/statusbar/sb-music index fcd0d449..87846f40 100755 --- a/.local/bin/statusbar/sb-music +++ b/.local/bin/statusbar/sb-music @@ -1,30 +1,15 @@ #!/bin/sh - filter() { if mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 3 ]; then song=$(mpc current -f "%artist% - %title%" | xargs -0 ) [ ${#song} -gt 35 ] && song="$(printf %.35s "$song")…" mpc | awk 'NR==2' | grep -q playing && icon="" || icon="" - echo " $icon $song " + echo "$icon $song" elif mpc 1>/dev/null 2>&1 && [ "$(mpc | wc -l)" -eq 1 ]; then - echo " ﱙ " + echo "ﱙ" else exit 1 fi } pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 & - -case $BLOCK_BUTTON in - 1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;; # right click, pause/unpause - 2) mpc toggle | filter ;; # right click, pause/unpause - 3) mpc status | filter ; notify-send " Music module" "\- Shows mpd song playing. -- ⏸ when paused. -- Left click opens ncmpcpp. -- Middle click pauses. -- Scroll changes track.";; # right click, pause/unpause - 4) mpc prev | filter ;; # scroll up, previous - 5) mpc next | filter ;; # scroll down, next - 6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;; - *) mpc status | filter ;; -esac diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume index 98f90cc4..370db04f 100755 --- a/.local/bin/statusbar/sb-volume +++ b/.local/bin/statusbar/sb-volume @@ -2,18 +2,7 @@ # Prints the current volume or ﱝ if muted. -case $BLOCK_BUTTON in - 1) setsid -f "$TERMINAL" -e pulsemixer ;; - 2) pamixer -t ;; - 4) pamixer --allow-boost -i 1 ;; - 5) pamixer --allow-boost -d 1 ;; - 3) notify-send "蓼Volume module" "\- Shows volume , ﱝ if muted. -- Middle click to mute. -- Scroll to change." ;; - 6) "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -[ $(pamixer --get-mute) = true ] && echo "ﱝ" && exit +[ "$(pamixer --get-mute)" = true ] && echo "ﱝ" && exit vol="$(pamixer --get-volume)" @@ -29,4 +18,4 @@ else echo "   " && exit fi -echo " $icon $vol% " +echo "$icon $vol%"