OSDN Git Service

new conky widgets
[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 "forced 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 '[0-9]%' &>/dev/null; then
35         export ISLAPTOP="true"
36         echo "laptop detected"
37 else
38         echo "not a laptop"
39 fi
40
41 if ! [ -e /opt/instantos/potato ]; then
42         picom &
43 else
44         echo "your computer is a potato"
45 fi
46
47 if ! xrdb -query -all | grep -q 'ScrollPage:.*false'; then
48         instantthemes a
49         xrdb ~/.Xresources
50 fi
51
52 mkdir -p /tmp/notifications &>/dev/null
53 if ! pgrep dunst; then
54         while :; do
55                 dunst
56                 sleep 10
57         done &
58 fi
59
60 onlinetrigger() {
61         instantwallpaper
62 }
63
64 if [ -z "$ISLIVE" ]; then
65         cd ~/instantos
66         if ! grep -q '....' ~/instantos/monitor/max.txt; then
67                 instantmonitor
68         fi
69
70         [ -e ~/instantos/monitor.sh ] &&
71                 bash ~/instantos/monitor.sh &
72
73         if ping google.com -c 2; then
74                 onlinetrigger
75         else
76                 # fall back to already installed wallpapers
77                 instantwallpaper offline
78                 for i in $(seq 10); do
79                         if ping google.com -c 2; then
80                                 onlinetrigger
81                                 break
82                         else
83                                 sleep 10
84                         fi
85                 done
86         fi
87
88         # apply german keybpard layout
89         if locale | grep -q 'de_DE'; then
90                 setxkbmap -layout de
91         fi
92
93         cat /usr/share/instantwidgets/tooltips.txt | shuf | head -1 >~/.cache/tooltips.txt
94         conky -c /usr/share/instantwidgets/tooltips.conf
95
96 else
97         instantmonitor
98         feh --bg-scale /usr/share/instantwallpaper/defaultphoto.png
99         conky -c /usr/share/instantwidgets/install.conf &
100         installapplet &
101         sleep 1
102         nm-applet &
103         sleep 1
104         pa-applet &
105 fi
106
107 # laptop specific background jobs
108 if [ -n "$ISLAPTOP" ]; then
109         command -v libinput-gestures \
110                 &>/dev/null &&
111                 libinput-gestures &
112         ! pgrep nm-applet && nm-applet &
113 fi
114
115 source /usr/bin/instantstatus