OSDN Git Service

manjaro cursors and fonts
[instantos/instantOS.git] / autostart.sh
1 #!/usr/bin/env bash
2
3 ####################################################
4 ## script for paperbenni-dwm autostart            ##
5 ####################################################
6
7 bashes=$(pgrep bash | wc -l)
8 if [ "$bashes" -gt 2 ]; then
9         echo "already running"
10         exit
11 fi
12
13 if acpi | grep -q '%'; then
14         export ISLAPTOP="true"
15         echo "laptop detected"
16 else
17         echo "not a laptop"
18 fi
19
20 if command -v picom &>/dev/null; then
21         picom &
22 else
23         compton &
24 fi
25
26 sleep 1
27
28 if command -v dunst &>/dev/null; then
29         mkdir -p /tmp/notifications &>/dev/null
30         if ! pgrep dunst; then
31                 while :; do
32                         dunst -print |
33                                 cat -v >/tmp/notifications/notif.txt
34                         sleep 30
35                 done &
36         fi
37 fi
38
39 [ -e /home/benjamin/paperbenni/monitor.sh ] &&
40         bash /home/benjamin/paperbenni/monitor.sh &
41
42 # chrome os wallpaper changer
43 [ -e /home/benjamin/paperbenni/menus/dm/wg.sh ] &&
44         bash /home/benjamin/paperbenni/menus/dm/wg.sh &
45
46 # apply german keybpard layout
47 if locale | grep -q 'de_DE'; then
48         setxkbmap -layout de
49 fi
50
51 # laptop specific background jobs
52 if [ -n "$ISLAPTOP" ]; then
53         command -v libinput-gestures \
54                 &>/dev/null &&
55                 libinput-gestures &
56         nm-applet &
57 fi
58
59 INTERNET="X"
60
61 REPETITIONS="xxxxxx"
62
63 command -v conky &>/dev/null && conky &
64
65 date=""
66
67 addstatus() {
68         date="$date[$@] "
69 }
70
71 # status bar loop
72 while :; do
73         if [ -e ~/.dwmsilent ]; then
74                 sleep 1m
75                 continue
76         fi
77
78         # run every 60 seconds
79         if [ "$REPETITIONS" = "xxxxxx" ]; then
80                 REPETITIONS="x"
81                 if ping -q -c 1 -W 1 8.8.8.8; then
82                         INTERNET="i"
83                 else
84                         INTERNET="^c#ff0000^X^d^"
85                 fi
86
87                 # battery indicator on laptop
88                 if [ -n "$ISLAPTOP" ]; then
89                         TMPBAT=$(acpi)
90                         if [[ $TMPBAT =~ "Charging" ]]; then
91                                 BATTERY="^c#00ff00^B"$(egrep -o '[0-9]*%' <<<"$TMPBAT")"^d^"
92                         else
93                                 BATTERY="B"$(egrep -o '[0-9]*%' <<<"$TMPBAT")
94                                 # make indicator red on low battery
95                                 if [ $(grep '[0-9]*' <<<$BATTERY) -lt 10 ]; then
96                                         BATTERY="^c#ff0000^$BATTERY^d^"
97                                 fi
98                         fi
99                 fi
100
101         else
102                 # increase counter
103                 REPETITIONS="$REPETITIONS"x
104         fi
105
106         addstatus "$(date +'%d-%m|%H:%M')"
107         addstatus "A$(amixer get Master | egrep -o '[0-9]{1,3}%' | head -1)"
108         [ -n "$ISLAPTOP" ] && addstatus "$BATTERY"
109         addstatus "$INTERNET"
110
111         xsetroot -name "$date"
112         date=""
113
114         sleep 10
115 done