diff --git a/.local/bin/README.md b/.local/bin/README.md index 5aa7d1f..3a7d947 100644 --- a/.local/bin/README.md +++ b/.local/bin/README.md @@ -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. diff --git a/.local/bin/dwmbar b/.local/bin/dwmbar deleted file mode 100755 index 28f8918..0000000 --- a/.local/bin/dwmbar +++ /dev/null @@ -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 diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery new file mode 100755 index 0000000..68a5e0d --- /dev/null +++ b/.local/bin/statusbar/sb-battery @@ -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 diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet new file mode 100755 index 0000000..112d0e3 --- /dev/null +++ b/.local/bin/statusbar/sb-internet @@ -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 + diff --git a/.local/bin/statusbar/sb-mailbox b/.local/bin/statusbar/sb-mailbox new file mode 100755 index 0000000..a29fcd3 --- /dev/null +++ b/.local/bin/statusbar/sb-mailbox @@ -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" + + diff --git a/.local/bin/statusbar/sb-mpdup b/.local/bin/statusbar/sb-mpdup new file mode 100755 index 0000000..f0ad1d5 --- /dev/null +++ b/.local/bin/statusbar/sb-mpdup @@ -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 + diff --git a/.local/bin/statusbar/sb-music b/.local/bin/statusbar/sb-music new file mode 100755 index 0000000..70be3a6 --- /dev/null +++ b/.local/bin/statusbar/sb-music @@ -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 diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume new file mode 100755 index 0000000..791e627 --- /dev/null +++ b/.local/bin/statusbar/sb-volume @@ -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 + diff --git a/.profile b/.profile index 2aee625..f9e1bdd 100644 --- a/.profile +++ b/.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" diff --git a/.xprofile b/.xprofile index 2c4a0b9..31e1afe 100644 --- a/.xprofile +++ b/.xprofile @@ -14,7 +14,7 @@ sbacklight set 3 & bat_notify & AC_notify & setbg & -dwmbar & +dwmblocks & xinput set-prop 'Synaptics TM3072-003' 'libinput Tapping Enabled' 1 & xinput set-prop 'Synaptics TM3072-003' 'libinput Natural Scrolling Enabled' 1 &