refactor(dwm): lock, start update, segregate status, etc.
This commit is contained in:
parent
30a3e1e211
commit
e0588cd6d1
5 changed files with 39 additions and 25 deletions
|
@ -81,7 +81,7 @@ static const char *dmenucmd[] = {
|
||||||
static const char *termcmd[] = { "alacritty", NULL };
|
static const char *termcmd[] = { "alacritty", NULL };
|
||||||
|
|
||||||
// general & sys
|
// general & sys
|
||||||
static const char *locksaver[] = { "i3lock", "-c", "#000000", NULL };
|
static const char *locksaver[] = { "/usr/local/bin/dwm-lock", NULL };
|
||||||
static const char *vol_up[] = { "amixer", "set", "Master", "5%+", NULL };
|
static const char *vol_up[] = { "amixer", "set", "Master", "5%+", NULL };
|
||||||
static const char *vol_down[] = { "amixer", "set", "Master", "5%-", NULL };
|
static const char *vol_down[] = { "amixer", "set", "Master", "5%-", NULL };
|
||||||
static const char *vol_mute[] = { "amixer", "set", "Master", "toggle", NULL };
|
static const char *vol_mute[] = { "amixer", "set", "Master", "toggle", NULL };
|
||||||
|
|
5
files/dwm/dwm-lock.sh
Executable file
5
files/dwm/dwm-lock.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
touch /tmp/$USER-screen.lock
|
||||||
|
i3lock ${@:--nefc "#000000"}
|
||||||
|
rm -f /tmp/$USER-screen.lock
|
|
@ -4,29 +4,6 @@ LITE=${LITE:-no}
|
||||||
|
|
||||||
xsetroot -solid black
|
xsetroot -solid black
|
||||||
|
|
||||||
#while loop to update statusbar with some goodies
|
|
||||||
while true; do
|
|
||||||
#memfreak to get it in MB
|
|
||||||
memfree=$(grep MemFree /proc/meminfo | awk '{ print $2 }')
|
|
||||||
memtotal=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
|
|
||||||
memfreak=$(((memtotal - memfree) / 1024))
|
|
||||||
#time
|
|
||||||
CLK=$(date +'%a %b %d %R:%S %Z')
|
|
||||||
#volume
|
|
||||||
VOL=$(amixer get Master | tail -1 | awk '{ print $5 }' | tr -d '[]')
|
|
||||||
#loadavg
|
|
||||||
AVG=$(cat /proc/loadavg | cut -d ' ' -f -3)
|
|
||||||
#network stats in Bytes
|
|
||||||
NW=$(dstat -n --nocolor 1 1 | tail -1 | awk '{ print $1, $2}')
|
|
||||||
battper=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
||||||
#this one is not so good, increases a delay of 1-2s of the updating.
|
|
||||||
#put it in the xsetrootname plz (tip of the day, do not put | as first char after "
|
|
||||||
xsetroot -name "$AVG | $memfreak MB | Bat: $battper% | Vol: $VOL | $CLK | "
|
|
||||||
sleep 1
|
|
||||||
done &
|
|
||||||
|
|
||||||
feh -z -Z --bg-scale $HOME/Pictures/background.*
|
|
||||||
|
|
||||||
start_apps() {
|
start_apps() {
|
||||||
nm-applet &
|
nm-applet &
|
||||||
flameshot &
|
flameshot &
|
||||||
|
@ -34,6 +11,8 @@ start_apps() {
|
||||||
firefox &
|
firefox &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ "$LITE" = "yes" ] || /usr/local/bin/dwm-status &
|
||||||
[ "$LITE" = "yes" ] || (sleep 1 && start_apps) &
|
[ "$LITE" = "yes" ] || (sleep 1 && start_apps) &
|
||||||
|
|
||||||
|
feh -zZ --bg-scale $HOME/Pictures/background.*
|
||||||
[ "${NO_DWM:-no}" = "yes" ] || exec dwm >/dev/null
|
[ "${NO_DWM:-no}" = "yes" ] || exec dwm >/dev/null
|
||||||
|
|
26
files/dwm/dwm-status.sh
Executable file
26
files/dwm/dwm-status.sh
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
xsetroot -solid black -name "starting dwm..."
|
||||||
|
|
||||||
|
#while loop to update statusbar with some goodies
|
||||||
|
while true; do
|
||||||
|
sleep 1
|
||||||
|
[ -f /tmp/$USER-screen.lock ] && continue
|
||||||
|
#memfreak to get it in MB
|
||||||
|
memfree=$(grep MemFree /proc/meminfo | awk '{ print $2 }')
|
||||||
|
memtotal=$(grep MemTotal /proc/meminfo | awk '{ print $2 }')
|
||||||
|
memfreak=$(((memtotal - memfree) / 1024))
|
||||||
|
#time
|
||||||
|
CLK=$(date +'%a %b %d %R:%S %Z')
|
||||||
|
#volume
|
||||||
|
VOL=$(amixer get Master | tail -1 | awk '{ print $5 }' | tr -d '[]')
|
||||||
|
#loadavg
|
||||||
|
AVG=$(cat /proc/loadavg | cut -d ' ' -f -3)
|
||||||
|
#network stats in Bytes
|
||||||
|
NW=$(dstat -n --nocolor 1 1 | tail -1 | awk '{ print $1, $2}')
|
||||||
|
battper=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||||
|
#this one is not so good, increases a delay of 1-2s of the updating.
|
||||||
|
#put it in the xsetrootname plz (tip of the day, do not put | as first char after "
|
||||||
|
xsetroot -name "$AVG | $memfreak MB | Bat: $battper% | Vol: $VOL | $CLK |"
|
||||||
|
done
|
||||||
|
|
|
@ -35,7 +35,11 @@ popd
|
||||||
chmod +x ./files/dwm/*.sh
|
chmod +x ./files/dwm/*.sh
|
||||||
|
|
||||||
$SUDO cp ./files/dwm/dwm-start.sh /usr/local/bin/dwm-start
|
$SUDO cp ./files/dwm/dwm-start.sh /usr/local/bin/dwm-start
|
||||||
|
$SUDO cp ./files/dwm/dwm-status.sh /usr/local/bin/dwm-status
|
||||||
$SUDO cp ./files/dwm/dwm-sync.sh /usr/local/bin/dwm-sync
|
$SUDO cp ./files/dwm/dwm-sync.sh /usr/local/bin/dwm-sync
|
||||||
|
$SUDO cp ./files/dwm/dwm-lock.sh /usr/local/bin/dwm-lock
|
||||||
|
|
||||||
|
$SUDO chmod +x /usr/local/bin/dwm-*
|
||||||
|
|
||||||
# DM entry
|
# DM entry
|
||||||
$SUDO cp ./files/dwm/dwm.desktop /usr/share/xsessions/dwm.desktop
|
$SUDO cp ./files/dwm/dwm.desktop /usr/share/xsessions/dwm.desktop
|
||||||
|
|
Loading…
Reference in a new issue