From 3df92328cd72edd10522dae651f7352543f5e387 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Sun, 11 Sep 2022 14:01:32 +0530 Subject: sbar changed and rm sxhkd --- .local/bin/sb-mpdup | 8 ++++++++ .local/bin/sb-music | 19 +++++++++++++++++++ .local/bin/sbar | 15 +++++++++++---- 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100755 .local/bin/sb-mpdup create mode 100755 .local/bin/sb-music (limited to '.local/bin') diff --git a/.local/bin/sb-mpdup b/.local/bin/sb-mpdup new file mode 100755 index 0000000..f67663a --- /dev/null +++ b/.local/bin/sb-mpdup @@ -0,0 +1,8 @@ +#!/bin/sh + +# This loop will update the mpd statusbar module whenever a command changes the +# music player's status. mpd must be running on X's start for this to work. + +while : ; do + mpc idle >/dev/null && kill -44 $(cat ~/.cache/pidofbar) || break +done diff --git a/.local/bin/sb-music b/.local/bin/sb-music new file mode 100755 index 0000000..7ea7032 --- /dev/null +++ b/.local/bin/sb-music @@ -0,0 +1,19 @@ +#!/bin/sh + +filter() { mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/⏸/g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;} + +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/sbar b/.local/bin/sbar index de324e4..c26f46b 100755 --- a/.local/bin/sbar +++ b/.local/bin/sbar @@ -17,6 +17,10 @@ update_time () { time="$(date "+[  %a %d %b ] [  %I:%M %P ]")" } +update_music () { + music="[ $(sb-music) ] " +} + # update_bat () { # # you might need to change the path depending on your device # read -r bat_status ;display" "RTMIN+n" trap "update_vol;display" "RTMIN" +trap "update_music;display" "RTMIN+10" # trap "update_bat;display" "RTMIN+2" # to update it from external commands ## kill -m "$(cat ~/.cache/pidofbar)" @@ -58,8 +63,10 @@ do # to update item ever n seconds with a offset of m ## [ $((sec % n)) -eq m ] && udpate_item [ $((sec % 5 )) -eq 0 ] && update_time # update time every 5 seconds + [ $((sec % 5 )) -eq 0 ] && update_vol # update vol every 5 seconds + [ $((sec % 5 )) -eq 0 ] && update_music # update music every 5 seconds [ $((sec % 5)) -eq 0 ] && update_cpu # update cpu every 15 seconds - [ $((sec % 15)) -eq 0 ] && update_memory + [ $((sec % 5)) -eq 0 ] && update_memory # [ $((sec % 60)) -eq 0 ] && update_bat #[ $((sec % 300)) -eq 1 ] && update_event -- cgit v1.2.3