-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdwm.sh
executable file
·89 lines (70 loc) · 1.92 KB
/
dwm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Fernando Carmona Varo
#---
# Wrapper script around my dwm window manager
#---
BUILDIR="$XDG_CONFIG_HOME/dwm/"
[ "$DISPLAY" ] || { echo "error: no DISPLAY available"; exit 1; }
# Update the status info in the bar
statusupd() {
TIME=$(date '+%a %F --%H:%M--')
LOAD=$(uptime | sed 's/.*, //')
#BAT=$(acpi -b | cut -d, -f 2)
STAT=$(statck -1)
#TRAFIC=$(vnstat --oneline | cut -d ";" -f 11)
# # check if my neightbor is connected
# HOSTS=""
# for h in 1
# do
# ping -c 1 "192.168.1.$h" && HOSTS="${HOSTS}.$h"
# done
# # use reduced traffic speed if it's connected
# if [ $(echo $HOSTS | wc -c) -gt 3 ]
# then
# transmission-remote --alt-speed
# else
# transmission-remote --no-alt-speed
# fi
# number of ARP entries
HOSTS=$(arp -a | wc -l)
xsetroot -name "$TIME {$STAT} <$LOAD> ☯$HOSTS"
#xsetroot -name "^[f3;$TIME ^[f2;^[i2;^[f0;$STAT^[i29; ^[f77F;$LOAD^[i15; ^[f292;^[i35;$HOSTS "
}
[ "$1" = "update" ] && {
statusupd
exit
}
while true
do
statusupd
sleep 40
done &
# if dwm is already running, only spawn status updater
pgrep "dwm$" >/dev/null && {
echo "dwm is already running, a status update daemon has been spawned, but dwm won't be re-run"
exit
}
# Set a known name to the WM so that some programs don't complain
if hash wmname >/dev/null 2>&1
then
wmname LG3D
else
xprop -root -f _NET_WM_NAME 8s -set _NET_WM_NAME "LG3D"
fi
# Run dwm in loop so it can restart (to close session pkill dwm.sh)
while true
do
if [ "$BUILDIR/config.h" -nt "$BUILDIR/dwm" ]
then
echo 'New dwm config.h found! compiling...'
( cd "$BUILDIR" && make ) 2>&1 | tee "$BUILDIR/build.log"
fi
# Run custom dwm if it exists (even if compilation failed)
if [ -e "$BUILDIR/dwm" ]
then
echo "Starting custom dwm from: $BUILDIR"
"$BUILDIR/dwm"
else
dwm
fi > "$BUILDIR/run.log" 2>&1
done