aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2025-04-03 21:32:14 -0400
committerBardofSprites <[email protected]>2025-04-03 21:32:14 -0400
commit7ff2f27a84c254d99a9e4d285e8da14453a48aa1 (patch)
tree1aff775af53fc6ea27de07b5ecebace535696c63
parent1ba0aaecfa3448e9ce01580b34c46e4ffa343098 (diff)
XMobar more scripts/modules
-rwxr-xr-xbin/.local/bin/scripts/status-plain/music-plain51
-rwxr-xr-xbin/.local/bin/scripts/status-plain/weather-plain54
-rw-r--r--xmonad/.config/xmobar/xmobarrc21
-rw-r--r--xmonad/.config/xmonad/xmonad.hs4
4 files changed, 124 insertions, 6 deletions
diff --git a/bin/.local/bin/scripts/status-plain/music-plain b/bin/.local/bin/scripts/status-plain/music-plain
new file mode 100755
index 0000000..60d8f4c
--- /dev/null
+++ b/bin/.local/bin/scripts/status-plain/music-plain
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# Music module script for dwmblocks
+
+truncate() {
+ echo "$1" | cut -c1-15
+}
+
+# Handle mouse events based on button clicks
+case $BLOCK_BUTTON in
+ 1) # Left click to pause/play
+ playerctl play-pause
+ pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
+ 2) # Middle click to open the music player
+ # Replace `your-music-player` with your actual music player command
+ emacs-launcher "music" & ;;
+ 3) # Right click to show notification
+ notify-send "šŸŽµ Music Module
+- Left click to play/pause.
+- Middle click to open music player.
+- Right click to show current track." ;;
+ 4) # Scroll up to go back
+ playerctl previous
+ pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
+ 5) # Scroll down to skip
+ playerctl next
+ pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" ;;
+esac
+
+# Get current track info
+artist="$(playerctl metadata artist 2>/dev/null || echo "none")"
+title="$(playerctl metadata title 2>/dev/null || echo "none")"
+
+# Truncate artist and title to 15 characters
+truncated_artist=$(truncate "$artist")
+truncated_title=$(truncate "$title")
+
+# Format the output as "artist - title"
+current_track="$truncated_artist - $truncated_title"
+
+playerstatus=$(playerctl status)
+
+case "$playerstatus" in
+ "Playing") icon="󰝚" ;;
+ "Paused") icon="" ;;
+ "Stopped") icon="ļ" ;;
+ "*") icon="" ;;
+esac
+
+# Print the current track
+echo "$icon $current_track"
diff --git a/bin/.local/bin/scripts/status-plain/weather-plain b/bin/.local/bin/scripts/status-plain/weather-plain
new file mode 100755
index 0000000..5de984b
--- /dev/null
+++ b/bin/.local/bin/scripts/status-plain/weather-plain
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# Displays today's precipication chance (ā˜”), and daily low (🄶) and high (šŸŒž).
+# Usually intended for the statusbar.
+
+url="${WTTRURL:-wttr.in}"
+weatherreport="${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport"
+
+# Get a weather report from 'wttr.in' and save it locally.
+getforecast() { curl -sf "$url/Louisville?M" > "$weatherreport" || exit 1; }
+
+# Forecast should be updated only once a day.
+checkforecast() {
+ [ -s "$weatherreport" ] && [ "$(stat -c %y "$weatherreport" 2>/dev/null |
+ cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ]
+}
+
+getprecipchance() {
+ echo "$weatherdata" | sed '16q;d' | # Extract line 16 from file
+ grep -wo "[0-9]*%" | # Find a sequence of digits followed by '%'
+ sort -rn | # Sort in descending order
+ head -1q # Extract first line
+}
+
+getdailyhighlow() {
+ echo "$weatherdata" | sed '13q;d' | # Extract line 13 from file
+ grep -o "m\\([-+]\\)*[0-9]\\+" | # Find temperatures in the format "m<signed number>"
+ sed 's/[+m]//g' | # Remove '+' and 'm'
+ sort -g | # Sort in ascending order
+ sed -e 1b -e '$!d' # Extract the first and last lines
+}
+
+readfile() { weatherdata="$(cat "$weatherreport")" ;}
+
+showweather() {
+ readfile
+ # printf "ā˜”%s 🄶%s°C šŸŒž%s°C\n" "$(getprecipchance)" $(getdailyhighlow)
+ printf " %s ļ‹œ %s°C  %s°C\n" "$(getprecipchance)" $(getdailyhighlow)
+}
+
+case $BLOCK_BUTTON in
+ 1) setsid -f "$TERMINAL" -n "floatterm" -c "floatterm" -g "150x35" -e less -Sfr "$weatherreport" ;;
+ 2) getforecast && showweather ;;
+ 3) notify-send "🌈 Weather module" "\- Left click for full forecast.
+- Middle click to update forecast.
+ā˜”: Chance of rain/snow
+🄶: Daily low
+šŸŒž: Daily high" ;;
+ 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
+esac
+
+checkforecast || getforecast
+
+showweather
diff --git a/xmonad/.config/xmobar/xmobarrc b/xmonad/.config/xmobar/xmobarrc
index 7b669aa..0972ff5 100644
--- a/xmonad/.config/xmobar/xmobarrc
+++ b/xmonad/.config/xmobar/xmobarrc
@@ -2,13 +2,26 @@ Config {
bgColor = "#181818"
, fgColor = "#e4e4e4"
, border = BottomB
- , borderColor = "#cc8c3c"
- , font = "xft:Iosevka Comfy-13"
+ , font = "xft:Iosevka Comfy-12"
+ , additionalFonts = ["Noto Color Emoji-12", "Iosevka Nerd Font"]
, position = TopH 22
, commands = [
-- Network activity monitor (dynamic interface resolution)
- Run Date "%Y-%m-%d (%a) %H:%M" "mydate" 10
+ Run Date "%Y-%m-%d (%a) %H:%M:%S" "mydate" 10
+ -- Run Com "<terminal app/script>" [<app arguments>] <template identifier> <refreshrate>
+ , Run Com "notmuch" ["count"] "mail" 600
+ , Run Com "music-plain" [] "music" 50
+ , Run Com "weather-plain" [] "weather" 100
, Run StdinReader -- text coming from xmonad
+ , Run DynNetwork [ "--template" , " :  <tx>kB/s  <rx>kB/s"
+ , "--Low" , "1000" -- units: B/s
+ , "--High" , "5000" -- units: B/s
+ , "--low" , "#73c936"
+ , "--normal" , "#ce5c00"
+ , "--high" , "#ff4f58"
+ ] 10
+ , Run ThermalZone 0 ["-t","ļ‹Š : <temp>C"] 30
+ , Run MultiCpu ["-H","95","--high","red","-t","[<autovbar>]","--","--contiguous-icons"] 10
]
- , template = "%StdinReader% }{ %mydate% "
+ , template = " %StdinReader% }{ <fc=#ffdd33>%weather%</fc> | <fc=#73c936> : %mail% unread</fc> | <fc=#96a6c8>%music%</fc> | 󰍛 : %multicpu% | %thermal0% | %dynnetwork% | 󰃰: %mydate% "
}
diff --git a/xmonad/.config/xmonad/xmonad.hs b/xmonad/.config/xmonad/xmonad.hs
index 51c6805..76487b0 100644
--- a/xmonad/.config/xmonad/xmonad.hs
+++ b/xmonad/.config/xmonad/xmonad.hs
@@ -30,12 +30,11 @@ main :: IO()
main = do
nScreens <- countScreens
xmprocs <- mapM (\s -> spawnPipe $ "xmobar -x " ++ show s) [0 .. (nScreens - 1)]
- xmprocs' <- mapM (\s -> spawnPipe $ "xmobar -x " ++ show s) [0 .. (nScreens - 1)] -- Second set of bars
xmonad
. docks
. ewmhFullscreen
. ewmh
- $ myConfig (xmprocs ++ xmprocs')
+ $ myConfig xmprocs
term :: String
term = "st"
@@ -104,6 +103,7 @@ myKeys =
, ("M-<Return>", spawn term)
, ("M-d", spawn "dmenu_run")
, ("M-S-x", spawn "sysact")
+ , ("M-S-z", spawn "boomer")
, ("M-p", spawn "st -e alsamixer")
, ("M-S-m", spawn "wallpaper.sh")
, ("<Print>", spawn "maimpick")