diff --git a/.dwm/bar.sh b/.dwm/bar.sh index 9fc5e90..e8f8ca5 100755 --- a/.dwm/bar.sh +++ b/.dwm/bar.sh @@ -1,24 +1,36 @@ #!/bin/bash -interval=10 - cpu() { - cpu_val=$(grep -o "^[^ ]*" /proc/loadavg) - printf "^c#3b414d^ ^b#7ec7a2^ LOAD" - printf "^c#abb2bf^ ^b#353b45^ $cpu_val" + echo -n "^c#3b414d^^b#7ec7a2^ CPU " + echo -n "^c#abb2bf^^b#353b45^ $(grep -o "^[^ ]*" /proc/loadavg)" } mem() { - printf "^c#3b414d^^b#c7957e^  " - printf "^c#abb2bf^ ^b#353b45^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)" + echo -n "^c#3b414d^^b#c7957e^ MEM " + echo -n "^c#abb2bf^^b#353b45^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)" } clock() { - printf "^c#1e222a^^b#668ee3^ 󱑆 " - printf "^c#1e222a^^b#7aa2f7^ $(date '+%a, %I:%M %p') " + echo -n "^c#1e222a^^b#668ee3^ 󱑆 " + echo -n "^c#1e222a^^b#7aa2f7^ $(date '+%a, %I:%M %p') " +} + +root() { + echo -n "^c#3b414d^^b#ad7ec7^ / " + echo -n "^c#abb2bf^^b#353b45^ $(df -h / | awk '{if ($1 != "Filesystem") print $4" free"}')" +} + +pulse() { + echo -n "^c#3b414d^^b#7ec0c7^ 墳 " + echo -n "^c#abb2bf^^b#353b45^ $(awk -F"[][]" '/Left:/ { print $2 }' <(amixer -D pulse sget Master))" +} + +spotify() { + echo -n "^c#3b414d^^b#a7c77e^  " + echo -n "^c#abb2bf^^b#353b45^ $(playerctl metadata | awk '{if ($2 == "xesam:title") {s = ""; for (i = 3; i <= NF; i++) s = s $i " "; print s}}')" } while true; do - sleep $interval - xsetroot -name "$(cpu) $(mem) $(clock)" + xsetroot -name "$(spotify)$(pulse) $(root) $(cpu) $(mem) $(clock)" + sleep 2 done diff --git a/lemondwm/config.def.h b/lemondwm/config.def.h index 1702284..85db738 100644 --- a/lemondwm/config.def.h +++ b/lemondwm/config.def.h @@ -117,7 +117,17 @@ static const char *termcmd[] = {"alacritty", NULL}; // change this to your term static const char *rofi[] = {"rofi", "-show", "drun", "-font", "Mononoki Nerd Font 12", NULL}; static const char *layoutmenu_cmd = "/home/lemon/.dwm/layoutmenu.sh"; // change lemon to your username +// media commands +static const char *pctlplaycmd[] = { "playerctl", "play-pause", NULL }; +static const char *pctlpausecmd[] = { "playerctl", "pause", NULL }; +static const char *pctlpreviouscmd[] = { "playerctl", "previous", NULL }; +static const char *pctlnextcmd[] = { "playerctl", "next", NULL }; +static const char *raisevolumecmd[] = { "amixer", "-D", "pulse", "sset", "Master", "5%+", NULL }; +static const char *lowervolumecmd[] = { "amixer", "-D", "pulse", "sset", "Master", "5%-", NULL }; +static const char *mutecmd[] = { "amixer", "-D", "pulse", "sset", "Master", "toggle-mute", NULL }; +#include static Key keys[] = { + // general stuff {MODKEY, XK_d, spawn, {.v = rofi}}, {MODKEY, XK_Return, spawn, {.v = termcmd }}, {MODKEY, XK_u, spawn, SHCMD("gnome-screenshot -i")}, @@ -145,7 +155,20 @@ static Key keys[] = { {MODKEY, XK_0, view, {.ui = ~0}}, {MODKEY | ShiftMask, XK_comma, tagmon, {.i = -1}}, {MODKEY | ShiftMask, XK_period, tagmon, {.i = +1}}, + {MODKEY | ControlMask, XK_q, quit, {0}}, + {MODKEY, XK_e, hidewin, {0}}, + {MODKEY | ShiftMask, XK_e, restorewin, {0}}, + // media keys + { 0, XF86XK_AudioPlay, spawn, {.v = pctlplaycmd } }, + { 0, XF86XK_AudioPause, spawn, {.v = pctlpausecmd } }, + { 0, XF86XK_AudioNext, spawn, {.v = pctlnextcmd } }, + { 0, XF86XK_AudioPrev, spawn, {.v = pctlpreviouscmd } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = raisevolumecmd } }, + { 0, XF86XK_AudioLowerVolume, spawn, {.v = lowervolumecmd } }, + { 0, XF86XK_AudioMute, spawn, {.v = mutecmd } }, + + // tags TAGKEYS(XK_1, 0) TAGKEYS(XK_2, 1) TAGKEYS(XK_3, 2) @@ -154,11 +177,6 @@ static Key keys[] = { TAGKEYS(XK_6, 5) TAGKEYS(XK_7, 6) TAGKEYS(XK_8, 7) - - {MODKEY | ControlMask, XK_q, quit, {0}}, - {MODKEY, XK_e, hidewin, {0}}, - {MODKEY | ShiftMask, XK_e, restorewin, {0}}, - }; /* button definitions */