From a2469aedaf97f856db07571e2a4943cbd2b01034 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 6 Oct 2025 13:09:40 -0600 Subject: [PATCH] new statusbar --- config.h | 14 +++++++------- xsetroot.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ xsetsingle.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 7 deletions(-) create mode 100755 xsetroot.sh create mode 100755 xsetsingle.sh diff --git a/config.h b/config.h index e935153..f7f6e0f 100644 --- a/config.h +++ b/config.h @@ -7,7 +7,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=18", "Noto Color Emoji:size=18" }; +static const char *fonts[] = { "monospace:size=18", "Symbola:size=18" }; static const char dmenufont[] = "monospace:size=22"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; @@ -100,12 +100,12 @@ static const Key keys[] = { TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) { MODKEY|ShiftMask, XK_x, quit, {0} }, - { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer --decrease 5; kill -44 $(pidof dwmblocks)") }, - { 0, XF86XK_AudioMute, spawn, SHCMD("pamixer --toggle-mute; kill -44 $(pidof dwmblocks)") }, - { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer --increase 5; kill -44 $(pidof dwmblocks)") }, - { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("brightnessctl set 10%+; kill -44 $(pidof dwmblocks)") }, - { 0, XF86XK_MonBrightnessDown,spawn, SHCMD("brightnessctl set 10%-; kill -44 $(pidof dwmblocks)") }, - { 0, XF86XK_AudioMicMute, spawn, SHCMD("sh /usr/local/scripts/mutemic.sh; kill -44 $(pidof dwmblocks)") }, + { 0, XF86XK_AudioLowerVolume, spawn, SHCMD("pamixer --decrease 5; /usr/local/scripts/xsetsingle.sh") }, + { 0, XF86XK_AudioMute, spawn, SHCMD("pamixer --toggle-mute; /usr/local/scripts/xsetsingle.sh") }, + { 0, XF86XK_AudioRaiseVolume, spawn, SHCMD("pamixer --increase 5; /usr/local/scripts/xsetsingle.sh") }, + { 0, XF86XK_MonBrightnessUp, spawn, SHCMD("brightnessctl set 10%+; /usr/local/scripts/xsetsingle.sh") }, + { 0, XF86XK_MonBrightnessDown,spawn, SHCMD("brightnessctl set 10%-; /usr/local/scripts/xsetsingle.sh") }, + { 0, XF86XK_AudioMicMute, spawn, SHCMD("sh /usr/local/scripts/mutemic.sh; /usr/local/scripts/xsetsingle.sh") }, { 0, PrintScreenDWM, spawn, SHCMD("flameshot gui") }, { 0, XF86XK_AudioPlay, spawn, SHCMD("playerctl play-pause") }, }; diff --git a/xsetroot.sh b/xsetroot.sh new file mode 100755 index 0000000..8a068e4 --- /dev/null +++ b/xsetroot.sh @@ -0,0 +1,52 @@ +while true; do + micstat=$(pamixer --default-source --get-mute) + [[ $micstat = "false" ]] && micstat="βœ”οΈ" + [[ $micstat = "true" ]] && micstat="🚫" + + vol="$(pamixer --get-volume)%" + + if [ "$vol" -gt "70" ]; then + volicon="πŸ”Š" + elif [ "$vol" -lt "30" ]; then + volicon="πŸ”ˆ" + else + volicon="πŸ”‰" + fi + + [[ "$vol" = 0 || "$vol" = "" || $(pamixer --get-mute) = "true" ]] && volicon="πŸ”‡" && vol="" + + for battery in /sys/class/power_supply/BAT? + do + # Get its remaining capacity and charge status. + capacity=$(cat "$battery"/capacity 2>/dev/null) || break + status=$(sed "s/[Dd]ischarging/πŸ”‹/;s/[Nn]ot charging/πŸ›‘/;s/[Cc]harging/πŸ”Œ/;s/[Uu]nknown/♻️/;s/[Ff]ull/|⚑/" "$battery"/status) + + # If it is discharging and 25% or less, we will add a ❗ as a warning. + [ "$capacity" -le 25 ] && [ "$status" = "πŸ”‹" ] && warn="❗" + + batmsg=$(printf "%s%s%s%s%%" "$status" "$warn" "$capacity") + unset warn + done + + 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 + + xsetroot -name " πŸ”† $(brightnessctl get -P) / $volicon$vol / $micstat🎀 / $(free --mega | sed -n '2{p;q}' | awk '{printf ("%2.2fGB/%2.2fGB\n", ( $3 / 1000), ($2 / 1000))}') / $batmsg / $(date '+%a %d %b %Y') $icon $(date '+%R %p')" + + sleep 1 +done diff --git a/xsetsingle.sh b/xsetsingle.sh new file mode 100755 index 0000000..acba61a --- /dev/null +++ b/xsetsingle.sh @@ -0,0 +1,48 @@ +micstat=$(pamixer --default-source --get-mute) +[[ $micstat = "false" ]] && micstat="βœ”οΈ" +[[ $micstat = "true" ]] && micstat="🚫" + +vol="$(pamixer --get-volume)%" + +if [ "$vol" -gt "70" ]; then + volicon="πŸ”Š" +elif [ "$vol" -lt "30" ]; then + volicon="πŸ”ˆ" +else + volicon="πŸ”‰" +fi + +[[ "$vol" = 0 || "$vol" = "" || $(pamixer --get-mute) = "true" ]] && volicon="πŸ”‡" && vol="" + +for battery in /sys/class/power_supply/BAT? +do + # Get its remaining capacity and charge status. + capacity=$(cat "$battery"/capacity 2>/dev/null) || break + status=$(sed "s/[Dd]ischarging/πŸ”‹/;s/[Nn]ot charging/πŸ›‘/;s/[Cc]harging/πŸ”Œ/;s/[Uu]nknown/♻️/;s/[Ff]ull/|⚑/" "$battery"/status) + + # If it is discharging and 25% or less, we will add a ❗ as a warning. + [ "$capacity" -le 25 ] && [ "$status" = "πŸ”‹" ] && warn="❗" + + batmsg=$(printf "%s%s%s%s%%" "$status" "$warn" "$capacity") + unset warn +done + +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 + +xsetroot -name " πŸ”† $(brightnessctl get -P) / $volicon$vol / $micstat🎀 / $(free --mega | sed -n '2{p;q}' | awk '{printf ("%2.2fGB/%2.2fGB\n", ( $3 / 1000), ($2 / 1000))}') / $batmsg / $(date '+%a %d %b %Y') $icon $(date '+%R %p')"