OSDN Git Service

add applets to live session
[instantos/instantOS.git] / autostart.sh
1 #!/usr/bin/env bash
2
3 ####################################################
4 ## script for instantOS autostart            ##
5 ####################################################
6
7 if [ -z "$1" ]; then
8         bashes=$(pgrep bash | wc -l)
9         if [ "$bashes" -gt 2 ]; then
10                 echo "already running"
11                 exit
12         fi
13 else
14         echo "force run"
15 fi
16
17 cd
18 if ! [ -e instantos ]; then
19         instantdotfiles &
20         mkdir instantos
21 fi
22
23 # find out if we're on an installation medium
24 if command -v calamares_polkit &>/dev/null; then
25         ISLIVE="True"
26         echo "live session detected"
27 fi
28
29 # fix small graphical glitch on status bar startup
30 xdotool key 'super+2'
31 sleep 0.1
32 xdotool key 'super+1'
33
34 if acpi | grep -q '%' &>/dev/null; then
35         export ISLAPTOP="true"
36         echo "laptop detected"
37 else
38         echo "not a laptop"
39 fi
40
41 if command -v picom &>/dev/null; then
42         picom &
43 else
44         compton &
45 fi
46
47 sleep 1
48
49 mkdir -p /tmp/notifications &>/dev/null
50 if ! pgrep dunst; then
51         while :; do
52                 dunst
53                 sleep 10
54         done &
55 fi
56
57 if [ -z "$ISLIVE" ]; then
58         cd ~/instantos
59         if ! grep -q '....' ~/instantos/monitor/max.txt; then
60                 instantmonitor
61         fi
62
63         [ -e ~/instantos/monitor.sh ] &&
64                 bash ~/instantos/monitor.sh &
65
66         if ping google.com -c 2; then
67                 onlinetrigger
68         else
69                 instantwallpaper offline
70                 for i in $(seq 10); do
71                         if ping google.com -c 2; then
72                                 onlinetrigger
73                                 break
74                         else
75                                 sleep 10
76                         fi
77                 done
78         fi
79
80         # apply german keybpard layout
81         if locale | grep -q 'de_DE'; then
82                 setxkbmap -layout de
83         fi
84         command -v conky &>/dev/null && conky &
85
86 else
87         installapplet &
88         nm-applet &
89         pa-applet &
90         feh --bg-scale /usr/share/liveutils/wallpaper.png
91 fi
92
93 # laptop specific background jobs
94 if [ -n "$ISLAPTOP" ]; then
95         command -v libinput-gestures \
96                 &>/dev/null &&
97                 libinput-gestures &
98         ! pgrep nm-applet && nm-applet &
99 fi
100
101 source /usr/bin/instantstatus