feat: use dwmblocks as statusbar
remove .local/bin/dwmbar add .local/bin/statusbar scripts directory update .profile ($PATH) update .xprofile (dwmblocks at startup)
This commit is contained in:
parent
312ed19a7e
commit
10321a0d21
@ -23,7 +23,6 @@
|
||||
- dmenuopen : fuzzy-find a file and open it with appropriate application
|
||||
- dmenuumount : unmount USB drives through a `dmenu` prompt
|
||||
- dot : git wrapper to manage dotfiles
|
||||
- dwmbar : set the statusbar and updates every minute
|
||||
- fetch : display basic system infos
|
||||
- kbacklight : change keyboard backlight level
|
||||
- maker : create a basic makefile for **C/C++** project
|
||||
@ -47,3 +46,7 @@ This is the shell script I run just after I installed Arch. It does few things:
|
||||
- Download my personnal repos
|
||||
- Compile my WM (`dwm`), my binary launcher (`dmenu`) and my terminal emulator (`st`), which are part of the [suckless](https://suckless.org/) project.
|
||||
|
||||
## statusbar
|
||||
|
||||
A collection of scripts I call in my
|
||||
[dwmblocks](https://gitlab.com/swy7ch/dwmblocks) build.
|
||||
|
@ -1,86 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (adapted from Luke Smith - lukesmith.xyz)
|
||||
# @file : dwmbar
|
||||
# @license : MIT
|
||||
# @created : Wednesday May 20, 2020 18:14:14 CEST
|
||||
#
|
||||
# @description : set the statusbar in `dwm`
|
||||
# @dependencies : `xsetroot`
|
||||
######################################################################
|
||||
|
||||
|
||||
# Handle SIGTRAP signals sent by refbar to update the status bar immediately.
|
||||
trap 'update' 5
|
||||
|
||||
delim=" | " # Set the delimiter character.
|
||||
|
||||
status() { \
|
||||
# Get the volume of ALSA's master volume output.
|
||||
level="$(amixer sget Master | awk -F "[][]" ' { printf "%s", $2 }' | awk -F "%" '{printf $1}')"
|
||||
muted="$(amixer sget Master | awk -F "[][]" '/%/ { printf "%4s", $4 }' | awk '{printf $1}')"
|
||||
|
||||
if [ "$muted" = "off" ]; then
|
||||
printf " 婢 ---"
|
||||
else
|
||||
printf " 墳 %3d%%" $level
|
||||
fi
|
||||
|
||||
printf "$delim"
|
||||
|
||||
# Wifi quality percentage and icon if ethernet is connected.
|
||||
wifi="$(grep "^\s*w" /proc/net/wireless | awk '{ printf int($3 * 100 / 70) }')"
|
||||
[ $wifi -ne 0 ] && printf "索 %3d%%" $wifi || printf "索 ---"
|
||||
eth="$(cat /sys/class/net/enp0s25/operstate)"
|
||||
if [ "up" = "$eth" ]; then
|
||||
printf " / "
|
||||
fi
|
||||
|
||||
printf "$delim"
|
||||
|
||||
# Will show all batteries with approximate icon for remaining power.
|
||||
# Or show that the computer is plugged to a power source
|
||||
# In any case, show the remaining battery percentage
|
||||
AC_ON="$(cat /sys/class/power_supply/AC/online)"
|
||||
for x in /sys/class/power_supply/BAT?/capacity;
|
||||
do
|
||||
if [ $AC_ON -eq 0 ]; then
|
||||
case "$(cat "$x")" in
|
||||
10[1-9]) printf " %3d%%" ;;
|
||||
100|9[0-9]|8[0-9]) printf " %3d%%" $(cat "$x") ;;
|
||||
7[0-9]|6[0-9]) printf " %3d%%" $(cat "$x") ;;
|
||||
5[0-9]|4[0-9]) printf " %3d%%" $(cat "$x") ;;
|
||||
3[0-9]|2[0-9]) printf " %3d%%" $(cat "$x") ;;
|
||||
*) printf " %3d%%" $(cat "$x") ;;
|
||||
esac
|
||||
else
|
||||
printf " %3d%%" $(cat "$x")
|
||||
fi
|
||||
done && printf "$delim"
|
||||
|
||||
# Date and time.
|
||||
date '+%b. %d - %I:%M%p'
|
||||
}
|
||||
|
||||
update() { \
|
||||
# So all that big status function was just a command that quicking gets
|
||||
# what we want to be the statusbar. This xsetroot command is what sets
|
||||
# it. Note that the tr command replaces newlines with spaces. This is
|
||||
# to prevent some weird issues that cause significant slowing of
|
||||
# everything in dwm. Note entirely sure of the cause, but again, the tr
|
||||
# command easily avoids it.
|
||||
xsetroot -name "$(status | tr '\n' ' ')" &
|
||||
wait
|
||||
}
|
||||
|
||||
|
||||
while :; do
|
||||
update
|
||||
# Sleep for a minute after changing the status bar before updating it
|
||||
# again. We run sleep in the background and use wait until it finishes,
|
||||
# because traps can interrupt wait immediately, but they can't do that
|
||||
# with sleep.
|
||||
sleep 60 &
|
||||
wait
|
||||
done
|
34
.local/bin/statusbar/sb-battery
Executable file
34
.local/bin/statusbar/sb-battery
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (swytch@$HOSTNAME)
|
||||
# @file : sb-battery
|
||||
# @license : MIT
|
||||
# @created : Saturday Feb 13, 2021 17:19:04 CET
|
||||
#
|
||||
# @description : battery block dwmblocks
|
||||
######################################################################
|
||||
|
||||
|
||||
# Will show all batteries with approximate icon for remaining power.
|
||||
# Or show that the computer is plugged to a power source
|
||||
# In any case, show the remaining battery percentage
|
||||
for bat in /sys/class/power_supply/BAT?/
|
||||
do
|
||||
status="$(cat "$bat/status")"
|
||||
capacity="$(cat "$bat/capacity")"
|
||||
if [ "$status" = "Charging" ]; then
|
||||
status=""
|
||||
elif [ "$status" = "Full" ];
|
||||
printf "%s FULL" "$status";
|
||||
else
|
||||
case "$capacity" in
|
||||
100|9[0-9]|8[0-9]) status="" ;;
|
||||
7[0-9]|6[0-9]) status="" ;;
|
||||
5[0-9]|4[0-9]) status="" ;;
|
||||
3[0-9]|2[0-9]) status="" ;;
|
||||
*) status="" ; [ "$status" != "Charging" ] && notify;;
|
||||
esac
|
||||
fi
|
||||
printf "%s %3d%%\n" "$status" "$capacity";
|
||||
done && return 0
|
20
.local/bin/statusbar/sb-internet
Executable file
20
.local/bin/statusbar/sb-internet
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (swytch@$HOSTNAME)
|
||||
# @file : sb-internet
|
||||
# @license : MIT
|
||||
# @created : Saturday Feb 13, 2021 17:35:49 CET
|
||||
#
|
||||
# @description : internet block for dwmblocks
|
||||
######################################################################
|
||||
|
||||
|
||||
# Wifi quality percentage and icon if ethernet is connected.
|
||||
wifi="$(grep "^\s*w" /proc/net/wireless | awk '{ printf int($3 * 100 / 70) }')"
|
||||
[ $wifi -ne 0 ] && printf "直 %3d%%" $wifi || printf "睊 ---"
|
||||
eth="$(cat /sys/class/net/enp0s25/operstate)"
|
||||
if [ "up" = "$eth" ]; then
|
||||
printf " / "
|
||||
fi
|
||||
|
19
.local/bin/statusbar/sb-mailbox
Executable file
19
.local/bin/statusbar/sb-mailbox
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (swytch@$HOSTNAME)
|
||||
# @file : sb-mailbox
|
||||
# @license : MIT
|
||||
# @created : Saturday Feb 13, 2021 18:15:13 CET
|
||||
#
|
||||
# @description : mail block for dwmblocks
|
||||
######################################################################
|
||||
|
||||
|
||||
unread="$(find "${XDG_DATA_HOME:-$HOME/.local/share}"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
|
||||
|
||||
pidof mbsync >/dev/null 2>&1 && icon=""
|
||||
|
||||
[ "$unread" = "0" ] && [ "$icon" = "" ] || echo " $unread$icon"
|
||||
|
||||
|
16
.local/bin/statusbar/sb-mpdup
Executable file
16
.local/bin/statusbar/sb-mpdup
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (swytch@$HOSTNAME)
|
||||
# @file : sb-mpdup
|
||||
# @license : MIT
|
||||
# @created : Saturday Feb 13, 2021 18:04:04 CET
|
||||
#
|
||||
# @description : update music block for dwmblocks
|
||||
######################################################################
|
||||
|
||||
|
||||
while : ; do
|
||||
mpc idle >/dev/null && kill -39 $(pidof dwmblocks) || break
|
||||
done
|
||||
|
18
.local/bin/statusbar/sb-music
Executable file
18
.local/bin/statusbar/sb-music
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (swytch@$HOSTNAME)
|
||||
# @file : sb-music
|
||||
# @license : MIT
|
||||
# @created : Saturday Feb 13, 2021 18:05:21 CET
|
||||
#
|
||||
# @description : music block for dwmblocks
|
||||
######################################################################
|
||||
|
||||
|
||||
mpc="$(mpc --format "%albumartist% - %title%")"
|
||||
format() { tac | sed "s/^volume: n\/a.*/ 🎵 ---/g;/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/ ⏸/g;s/\\[playing\\].*/ 🎵/g" | paste -sd ' ' -;}
|
||||
|
||||
pgrep -f sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 &
|
||||
|
||||
echo "$mpc" | format
|
25
.local/bin/statusbar/sb-volume
Executable file
25
.local/bin/statusbar/sb-volume
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : swytch (swytch@$HOSTNAME)
|
||||
# @file : sb-volume
|
||||
# @license : MIT
|
||||
# @created : Saturday Feb 13, 2021 17:51:16 CET
|
||||
#
|
||||
# @description : volume block for dwmblocks
|
||||
######################################################################
|
||||
|
||||
[ "1" = $(pulsemixer --get-mute) ] && echo "婢 ---" && exit
|
||||
|
||||
vol="$(pulsemixer --get-volume | awk -F " " '{ printf "%d", $1 }')"
|
||||
|
||||
if [ "$vol" -gt "70" ]; then
|
||||
icon="墳"
|
||||
elif [ "$vol" -lt "30" ]; then
|
||||
icon="奄"
|
||||
else
|
||||
icon="奔"
|
||||
fi
|
||||
|
||||
printf "%s %3d%%" $icon $vol
|
||||
|
2
.profile
2
.profile
@ -23,7 +23,7 @@ export ANDROID_EMULATOR_HOME="$XDG_DATA_HOME/android/emulator"
|
||||
export CARGO_HOME="$XDG_DATA_HOME/cargo"
|
||||
|
||||
## paths
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
export PATH="$(find $HOME/.local/bin -type d | tr '\n' ':' | sed 's/:$//'):$PATH"
|
||||
|
||||
## default programs
|
||||
export SUDO_ASKPASS="$HOME/.local/bin/dmenupass"
|
||||
|
Reference in New Issue
Block a user