From f862b777ec7f0d85199b303a1943d2e48508c2cc Mon Sep 17 00:00:00 2001 From: tiyn Date: Sat, 9 Mar 2024 02:48:17 +0100 Subject: [PATCH] statusbar/sxhkd: updated player interface and cleaned up --- .config/sxhkd/sxhkdrc | 10 +++++--- .local/bin/etc/statusbar/cpu | 14 +++++++++--- .local/bin/etc/statusbar/disk | 16 +++++++++++-- .local/bin/etc/statusbar/gpu | 14 ++++++++++-- .local/bin/etc/statusbar/internet | 21 ++++++++++++++--- .local/bin/etc/statusbar/memory | 15 ++++++++++-- .local/bin/etc/statusbar/player | 38 +++++++++++++++++++++++++++++++ .local/bin/etc/statusbar/volume | 10 ++++---- .local/bin/etc/sxhkd/audio/lmc | 9 ++++++++ 9 files changed, 127 insertions(+), 20 deletions(-) create mode 100755 .local/bin/etc/statusbar/player diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 5dbfe99..f88429c 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -11,11 +11,15 @@ super + r dmenu_run -F -i -c -l 20 super + a - playerctl previous + lmc previous super + s - playerctl play-pause + lmc playpause super + d - playerctl next + lmc next +super + c + lmc loop +super + x + lmc shuffle super + f $TERMINAL -e $FILE diff --git a/.local/bin/etc/statusbar/cpu b/.local/bin/etc/statusbar/cpu index 1fef6fe..b840bd6 100755 --- a/.local/bin/etc/statusbar/cpu +++ b/.local/bin/etc/statusbar/cpu @@ -2,8 +2,6 @@ model=$(cat /proc/cpuinfo | grep "model name" | head -n1) -icon="^b#282828^^c#dfdfdf^  ^d^" - if printf "$model " | grep -Fqe "AMD"; then temp=$(sensors | awk '/Tctl/ {print $2}') else @@ -12,4 +10,14 @@ fi temp=$(printf %3s $(echo ${temp##*+} | sed "s/\..*//") | tr ' ' ' ') -echo "$icon $temp°C" +if [ $temp -gt 100 ] +then + icon="^b#282828^^c#ff0000^  ^d^" +elif [ $temp -gt 80 ] +then + icon="^b#282828^^c#ffff00^  ^d^" +else + icon="^b#282828^^c#dfdfdf^  ^d^" +fi + +echo "$icon" diff --git a/.local/bin/etc/statusbar/disk b/.local/bin/etc/statusbar/disk index 7621eef..8ab67a1 100755 --- a/.local/bin/etc/statusbar/disk +++ b/.local/bin/etc/statusbar/disk @@ -3,9 +3,21 @@ # Status bar module for disk space # $1 should be drive mountpoint -disk="/" +disk="/home" [ ! -z "$1" ] && disk="$1" icon="$disk" -printf "^b#282828^^c#dfdfdf^ 󰗮 ^d^ %s\n" "$(df -h "$disk" | awk ' /[0-9]/ {print $3 "/" $2}')" +free=$(df "$disk" | awk ' /[0-9][0-9]/ {print $4}') + +if [ $free -gt 104857600 ] +then + icon="^b#282828^^c#dfdfdf^ 󰗮 ^d^" +elif [ $free -gt 52428800 ] +then + icon="^b#282828^^c#ffff00^ 󰗮 ^d^" +else + icon="^b#282828^^c#ff0000^ 󰗮 ^d^" +fi + +printf "$icon %s" diff --git a/.local/bin/etc/statusbar/gpu b/.local/bin/etc/statusbar/gpu index 2b5160a..499a7fd 100755 --- a/.local/bin/etc/statusbar/gpu +++ b/.local/bin/etc/statusbar/gpu @@ -1,6 +1,6 @@ #!/bin/sh -icon="^b#282828^^c#dfdfdf^  ^d^" +icon="^b#282828^^c#dfdfdf^ ^d^" temp="" @@ -12,4 +12,14 @@ else return fi -echo "$icon $temp°C" +if [ $temp -gt 100 ] +then + icon="^b#282828^^c#ff0000^  ^d^" +elif [ $temp -gt 80 ] +then + icon="^b#282828^^c#ffff00^  ^d^" +else + icon="^b#282828^^c#dfdfdf^  ^d^" +fi + +echo "$icon" diff --git a/.local/bin/etc/statusbar/internet b/.local/bin/etc/statusbar/internet index 89309fb..743fe89 100755 --- a/.local/bin/etc/statusbar/internet +++ b/.local/bin/etc/statusbar/internet @@ -2,9 +2,24 @@ wifipercent=" 0" -[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="^c#ff0000^ ^d^" +[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon="^c#ff0000^ ^d^" && wifistatus="down" -[ ! -n "${wifiicon+var}" ] && wifiicon="^c#dfdfdf^ ^d^" && wifipercent=$(grep "^\s*w" /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') +[ ! -n "${wifiicon+var}" ] && wifistatus="up" && wifipercent=$(grep "^\s*w" /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') wifipercent=$(printf %3s $wifipercent | tr ' ' ' ') -echo "$(cat /sys/class/net/e*/operstate | sed "s/down/^b#282828^^c#ff0000^  /;s/up/^b#282828^^c#dfdfdf^ 󰈀 /")" "$wifiicon" "$wifipercent%" + +if [ $wifistatus = "up" ] +then + if [ $wifipercent -gt 75 ] + then + wifiicon="^b#282828^^c#dfdfdf^  ^d^" + elif [ $wifipercent -gt 40 ] + then + wifiicon="^b#282828^^c#ffff00^  ^d^" + else + wifiicon="^b#282828^^c#ff0000^  ^d^" + fi +fi + + +echo "$(cat /sys/class/net/e*/operstate | sed "s/down/^b#282828^^c#ff0000^  ^d^/;s/up/^b#282828^^c#dfdfdf^ 󰈀 ^d^/")" "$wifiicon" diff --git a/.local/bin/etc/statusbar/memory b/.local/bin/etc/statusbar/memory index 8e35ed7..d504ceb 100755 --- a/.local/bin/etc/statusbar/memory +++ b/.local/bin/etc/statusbar/memory @@ -2,5 +2,16 @@ icon="^b#282828^^c#dfdfdf^  ^d^ " total=$(free -h | awk '/^Mem:/ {print $3/$2}') -percent=$(printf %3s $(printf %-4s $total | tr ' ' '0' | cut -c1-4 | sed -e 's/\.//g' | sed -e 's/^0//g') | tr ' ' ' ')% -echo "$icon$percent" +percent=$(printf %3s $(printf %-4s $total | tr ' ' '0' | cut -c1-4 | sed -e 's/\.//g' | sed -e 's/^0//g') | tr ' ' ' ') + +if [ $percent -gt 75 ] +then + icon="^b#282828^^c#ff0000^  ^d^" +elif [ $percent -gt 50 ] +then + icon="^b#282828^^c#ffff00^  ^d^" +else + icon="^b#282828^^c#dfdfdf^  ^d^" +fi + +echo "$icon" diff --git a/.local/bin/etc/statusbar/player b/.local/bin/etc/statusbar/player new file mode 100755 index 0000000..c90048a --- /dev/null +++ b/.local/bin/etc/statusbar/player @@ -0,0 +1,38 @@ +#!/bin/sh + +playerctlstatus=$(playerctl status 2> /dev/null) +track="$(playerctl metadata "xesam:artist") - $(playerctl metadata "xesam:title")" +track=$(echo "$track" | cut -c1-40) +loop=$(playerctl loop) +shuffle=$(playerctl shuffle) + +if [ "$loop" = "Playlist" ] +then + loop_icon="^b#282828^^c#dfdfdf^  ^d^" +elif [ "$loop" = "Track" ] +then + loop_icon="^b#282828^^c#dfdfdf^  ^d^" +elif [ "$loop" = "None" ] +then + loop_icon="^b#282828^^c#dfdfdf^  ^d^" +fi + +if [ "$shuffle" = "Off" ] +then + shuffle_icon="^b#282828^^c#dfdfdf^  ^d^" +elif [ "$shuffle" = "On" ] +then + shuffle_icon="^b#282828^^c#dfdfdf^  ^d^" +fi + + +if [ "$playerctlstatus" = "" ] +then + echo "" +elif [ "$playerctlstatus" = "Playing" ] +then + echo "$track ^b#282828^^c#dfdfdf^ ▶️ ^d^ $loop_icon $shuffle_icon" +elif [ "$playerctlstatus" = "Paused" ] +then + echo "^b#282828^^c#dfdfdf^  ^d^ $loop_icon $shuffle_icon" +fi diff --git a/.local/bin/etc/statusbar/volume b/.local/bin/etc/statusbar/volume index 47cbbd9..426d526 100755 --- a/.local/bin/etc/statusbar/volume +++ b/.local/bin/etc/statusbar/volume @@ -3,19 +3,19 @@ vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2}' | sed -e 's/\.//g' | sed 's/^0*//')" if [ "$vol" -eq "0" ]; then - vol_info="^c#dfdfdf^ ^d^" + vol_info="^b#282828^^c#dfdfdf^  ^d^" elif [ "$vol" -gt "70" ]; then - vol_info="^c#dfdfdf^ ^d^" + vol_info="^b#282828^^c#dfdfdf^  ^d^" else - vol_info="^c#dfdfdf^ ^d^" + vol_info="^b#282828^^c#dfdfdf^  ^d^" fi $(wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q '\[MUTED\]') && vol_info="^c#ff0000^ ^d^" if wpctl get-volume @DEFAULT_SOURCE@ | grep -q '\[MUTED\]'; then - mic="^b#282828^^c#ff0000^  " + mic="^b#282828^^c#ff0000^  ^d^" else - mic="^b#282828^^c#dfdfdf^  " + mic="^b#282828^^c#dfdfdf^  ^d^" fi vol=$(printf %3s $vol | tr ' ' ' ') diff --git a/.local/bin/etc/sxhkd/audio/lmc b/.local/bin/etc/sxhkd/audio/lmc index f41e669..3b578ee 100755 --- a/.local/bin/etc/sxhkd/audio/lmc +++ b/.local/bin/etc/sxhkd/audio/lmc @@ -12,6 +12,11 @@ case "$1" in undeaf) wpctl set-mute @DEFAULT_SINK@ 0;; mute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 1;; unmute) wpctl set-mute @DEFAULT_AUDIO_SOURCE@ 0;; + previous) playerctl previous;; + playpause) playerctl play-pause;; + next) playerctl next;; + shuffle) playerctl shuffle toggle;; + loop) playerctl loop none;; *) cat << EOF lmc: cli music interface for pulse for those with divine intellect too grand to remember the pamixer commands. @@ -23,8 +28,12 @@ Allowed options: unmute unmute microphone deaf deaf sound undeaf undeaf sound + previous play previous song in player + playpause toggle play or pause in player + next play next song in player all else Print this message EOF esac pkill -RTMIN+4 $STATUSBAR +sleep 1 && pkill -RTMIN+9 $STATUSBAR