refactor(dwm): lock, start update, segregate status, etc.
This commit is contained in:
parent
9904c7d5f4
commit
84872dc103
5 changed files with 39 additions and 25 deletions
|
@ -81,7 +81,7 @@ static const char *dmenucmd[] = {
|
|||
static const char *termcmd[] = { "alacritty", NULL };
|
||||
|
||||
// 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_down[] = { "amixer", "set", "Master", "5%-", NULL };
|
||||
static const char *vol_mute[] = { "amixer", "set", "Master", "toggle", NULL };
|
||||
|
@ -121,7 +121,7 @@ static Key keys[] = {
|
|||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||
{ 0, XK_Print, spawn, {.v = screenshot } },
|
||||
{ Mod1Mask, XK_Print, spawn, {.v = screenshot_partial } },
|
||||
{ Mod1Mask, XK_Print, spawn, {.v = screenshot_partial } },
|
||||
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = vol_up } },
|
||||
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = vol_down } },
|
||||
{ 0, XF86XK_AudioMute, spawn, {.v = vol_mute } },
|
||||
|
|
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
|
||||
|
||||
#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() {
|
||||
nm-applet &
|
||||
flameshot &
|
||||
|
@ -34,6 +11,8 @@ start_apps() {
|
|||
firefox &
|
||||
}
|
||||
|
||||
[ "$LITE" = "yes" ] || /usr/local/bin/dwm-status &
|
||||
[ "$LITE" = "yes" ] || (sleep 1 && start_apps) &
|
||||
|
||||
feh -zZ --bg-scale $HOME/Pictures/background.*
|
||||
[ "${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
|
||||
|
||||
$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-lock.sh /usr/local/bin/dwm-lock
|
||||
|
||||
$SUDO chmod +x /usr/local/bin/dwm-*
|
||||
|
||||
# DM entry
|
||||
$SUDO cp ./files/dwm/dwm.desktop /usr/share/xsessions/dwm.desktop
|
||||
|
|
Loading…
Reference in a new issue