feat: hypr, neomutt, newsboat, pass
This commit is contained in:
parent
82ebb9bc4b
commit
908d26dc96
55 changed files with 568 additions and 558 deletions
118
bin/sbar
118
bin/sbar
|
@ -1,101 +1,105 @@
|
|||
#!/bin/bash
|
||||
|
||||
# INIT
|
||||
echo "$$" > "$HOME/.cache/pidofbar"
|
||||
|
||||
# MODULES
|
||||
update_crypto() {
|
||||
local c="$(crypto)"
|
||||
|
||||
[ -n c ] && crypto="$c |"
|
||||
function update_crypto() {
|
||||
local c; c="$(crypto)" && crypto="$c"
|
||||
}
|
||||
|
||||
update_cpu() {
|
||||
cpu=" $(grep -o "^[^ ]*" /proc/loadavg) |"
|
||||
function update_cpu() {
|
||||
cpu=" $(awk '{print $1}' /proc/loadavg)"
|
||||
}
|
||||
|
||||
update_memory() {
|
||||
memory=" $(free -h | sed -n '2s/\([^ ]* *\)\{2\}\([^ ]*\).*/\2/p') |"
|
||||
function update_memory() {
|
||||
memory=" $(free -h | awk '$1 == "Mem:" {print $3}')"
|
||||
}
|
||||
|
||||
update_bat() {
|
||||
local dir; dir="$(echo /sys/class/power_supply/BAT*/ | sort -n | tail -n1)"
|
||||
function update_bat() {
|
||||
local dir; dir="$(find /sys/class/power_supply/ -mindepth 1 -name 'BAT*' -print -quit)"
|
||||
local cap; cap="$(cat "$dir/capacity")"
|
||||
|
||||
bat="$(grep -q Charging "$dir/status" && printf '' || printf '')"
|
||||
bat="$bat $(cat "$dir/capacity")% |"
|
||||
{ grep -qv Discharging "$dir/status" && bat=" $cap%"; } ||
|
||||
{ [ "$cap" -gt 80 ] && bat=" $cap%"; } ||
|
||||
{ [ "$cap" -gt 60 ] && bat=" $cap%"; } ||
|
||||
{ [ "$cap" -gt 40 ] && bat=" $cap%"; } ||
|
||||
{ [ "$cap" -gt 20 ] && bat=" $cap%"; } ||
|
||||
{ bat=" $cap%"; }
|
||||
}
|
||||
|
||||
update_vol() {
|
||||
local v; v="$(wpctl get-volume '@DEFAULT_AUDIO_SINK@')"
|
||||
function update_sink_vol() {
|
||||
local sink; sink="$(wpctl get-volume '@DEFAULT_AUDIO_SINK@')"
|
||||
local vol;
|
||||
|
||||
if grep -q 'MUTED' <<< "$v"; then
|
||||
vol='🔇'
|
||||
if grep -q 'MUTED' <<< "$sink"; then
|
||||
sink_vol='🔇'
|
||||
else
|
||||
vol=" $((10#$(tr -dc '0-9' <<< "$v")))"
|
||||
vol="$(awk '{print int($2 * 100)}' <<< "$sink")"
|
||||
{ [ "$vol" -gt 67 ] && sink_vol=" $vol"; } ||
|
||||
{ [ "$vol" -gt 33 ] && sink_vol=" $vol"; } ||
|
||||
{ sink_vol=" $vol"; }
|
||||
fi
|
||||
vol="$vol |"
|
||||
}
|
||||
|
||||
update_wlp() {
|
||||
local sig; sig="$(grep wlp /proc/net/wireless | awk '{print $3 * 100}')"
|
||||
local ssid; ssid="$(nmcli device wifi show-password | grep SSID | sed 's/SSID: //')"
|
||||
function update_source_vol() {
|
||||
local source; source="$(wpctl get-volume '@DEFAULT_AUDIO_SOURCE@')"
|
||||
local vol;
|
||||
|
||||
if grep -q 'MUTED' <<< "$source"; then
|
||||
source_vol=""
|
||||
else
|
||||
vol="$(awk '{print int($2 * 100)}' <<< "$sink")"
|
||||
source_vol=" $(awk '{print int($2 * 100)}' <<< "$source")"
|
||||
fi
|
||||
}
|
||||
|
||||
function update_wlp() {
|
||||
local sig; sig="$(awk '$1 ~ "wlp" {print int($3)}' /proc/net/wireless)"
|
||||
local ssid; ssid="$(nmcli device wifi show-password | sed -n 's/SSID: //p')"
|
||||
|
||||
[ -z "$ssid" ] && wlp='⚠' && return
|
||||
[ -z "$sig" ] && sig=0
|
||||
|
||||
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/d9b06a95/src/libnmc-base/nm-client-utils.c#L628
|
||||
{ [ "$sig" -gt 5600 ] && wlp="▂▄▆█ $ssid"; } ||
|
||||
{ [ "$sig" -gt 3850 ] && wlp="▂▄▆_ $ssid"; } ||
|
||||
{ [ "$sig" -gt 1650 ] && wlp="▂▄__ $ssid"; } ||
|
||||
{ [ "$sig" -gt 275 ] && wlp="▂___ $ssid"; } ||
|
||||
{ wlp="____ $ssid"; }
|
||||
wlp="$wlp |"
|
||||
{ [ "$sig" -gt 56 ] && wlp="▂▄▆█ $ssid"; } ||
|
||||
{ [ "$sig" -gt 38 ] && wlp="▂▄▆_ $ssid"; } ||
|
||||
{ [ "$sig" -gt 21 ] && wlp="▂▄__ $ssid"; } ||
|
||||
{ [ "$sig" -gt 3 ] && wlp="▂___ $ssid"; } ||
|
||||
{ wlp="____ $ssid"; }
|
||||
}
|
||||
|
||||
update_time() {
|
||||
function update_time() {
|
||||
time="$(date "+%a %m/%d %R")"
|
||||
}
|
||||
|
||||
# modules that don't update on their own need to be run at the start for getting their initial value
|
||||
while [ -z "$(wpctl get-volume '@DEFAULT_AUDIO_SINK@' 2> /dev/null)" ]; do
|
||||
sleep 1
|
||||
done
|
||||
update_vol
|
||||
|
||||
reload_bar() {
|
||||
sec=0
|
||||
function display() {
|
||||
"${DISPLAYCMD[@]}" "$crypto | $cpu | $memory | $sink_vol $source_vol | $wlp | $bat | $time"
|
||||
}
|
||||
|
||||
display() {
|
||||
"${DISPLAYCMD[@]}" "$crypto $cpu $memory $vol $wlp $bat $time"
|
||||
}
|
||||
|
||||
# SIGNALING
|
||||
# trap '<function>;display' 'RTMIN+n'
|
||||
trap 'reload_bar;display' 'RTMIN'
|
||||
trap 'update_vol;display' 'RTMIN+1'
|
||||
trap 'update_crypto;display' 'RTMIN+2'
|
||||
# to update it from external commands
|
||||
## kill -m "$(cat ~/.cache/pidofbar)"
|
||||
# where m = 34 + n
|
||||
|
||||
if [ "$XDG_SESSION_TYPE" = wayland ]; then
|
||||
DISPLAYCMD=(echo)
|
||||
else
|
||||
DISPLAYCMD=(xsetroot -name)
|
||||
fi
|
||||
|
||||
# crypto & > /tmp
|
||||
# sleep 5 && cat /tmp
|
||||
# SIGNALING
|
||||
# trap '<function>;display' 'RTMIN+n'
|
||||
trap 'update_sink_vol;display' 'RTMIN'
|
||||
# to update it from external commands
|
||||
## kill -m "$(cat ~/.cache/pidofbar)"
|
||||
# where m = 34 + n
|
||||
|
||||
echo "$$" > "$HOME/.cache/pidofbar"
|
||||
|
||||
sec=0
|
||||
while true; do
|
||||
[ "$((sec % 300))" = 0 ] && update_crypto
|
||||
[ "$((sec % 10))" = 0 ] && {
|
||||
update_time
|
||||
[ "$((sec % 10))" = 0 ] && {
|
||||
update_cpu
|
||||
update_memory
|
||||
update_bat
|
||||
update_sink_vol
|
||||
update_source_vol
|
||||
update_wlp
|
||||
update_bat
|
||||
update_time
|
||||
display
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue