-
Notifications
You must be signed in to change notification settings - Fork 0
/
s_wm_autostart
executable file
·99 lines (75 loc) · 2.69 KB
/
s_wm_autostart
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
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# Bin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Bin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Bin. If not, see <https://www.gnu.org/licenses/>.
# Description: auto start programs
#DEPS=(bash command nohup pgrep awk mako emacs udiskie mpd firefox)
#LOCAL_BIN="$HOME/.local/bin"
# =========================== HELPERS
is_array() {
# type: boolean
# description: is argument an array?
local var=$1
[[ $(declare -p "$var" 2>/dev/null) =~ "declare -a" ]]
}
not_found() {
# type: boolean
# description: check if program executable is found
local app=$(echo "$1" | awk '{ print $1}') # get first word of command string with options given
[[ ! -x $(command -v "$app") ]]
}
is_running() {
# type: boolean
# description: return if PROGRAM is running
[[ $(pgrep -f "$1") ]]
}
run() {
# type: void
# description: run program as gnu bash background process
nohup bash -c "$1" &
}
dolist() {
# type: void
# argument: receive a single array list of programs, may be an array with arrays.
# description: given a list of programs, before running perform a few checkers.
local apps=("$@")
for app in "${apps[@]}"; do
if is_array "${app[@]}"; then
printf -v app_string ' %s' "${!app}"
app_string=${app_string:1} # remove the leading space
echo "array: ${app} - length: ${#app[@]} - string: ${app_string}"
# not_found "${subapp[0]}" && continue
# run "${subapp[0]}"
else
echo "word: $app"
# not_found "$app" && continue
# is_running "$app" && continue
# run "$app"
fi
done
}
# =========================== PROGRAMS w/ ARGS
declare -a mxbook=(emacs -T books ~/Documents/books)
declare -a mxorg=(emacs -T Org ~/Documents/org)
declare -a mxpersonal=(emacs -T Personal ~/Documents/personal)
declare -a mxwork=(emacs -T Work ~/Documents/work)
declare -a udiskie_verbose=(udiskie --notify --tray)
# =========================== LISTS OF PROGRAMS
# declare -a TOOLS=("udiskie_verbose" mako)
# declare -a APPS=("mxbook" "mxorg" "mxpersonal" "mxwork" firefox)
# declare -a WAYLAND=(foot)
# # =========================== RUN
# dolist "${TOOLS[@]}"
# dolist "${APPS[@]}"
# dolist "${WAYLAND[@]}"
# # blueman-applet # "nm-applet --indicator"
# nyxt icecat google-chrom e