~mil/sxmo-utils

ref: f7698e4a25f11c5d673c9c41d46d11c131ae866e sxmo-utils/scripts/core/sxmo_common.sh -rw-r--r-- 7.1 KiB
f7698e4aMaxim Karasev Move operating system detection to sxmo_common a month ago
                                                                                
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#!/usr/bin/env sh

# This script is meant to be sourced by various sxmo scripts
# and defines some common settings

# Small optimization to guard against including the script unnecessarily
[ "$SXMO_COMMON_INCLUDED" = "1" ] && return 0;

# we disable shellcheck SC2034 (variable not used)
# for all the variables we define here

# Determine current operating system
if [ -f /etc/os-release ]; then
	# freedesktop.org and systemd
	# shellcheck disable=SC2034
	. /etc/os-release
	export OS="$NAME"
else
	export OS="Unknown"
fi

# shellcheck disable=SC2034
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-$HOME/.local/run}"
# shellcheck disable=SC2034
export NOTIFDIR="${XDG_DATA_HOME:-$HOME/.local/share}"/sxmo/notifications
# shellcheck disable=SC2034
export CACHEDIR="${XDG_CACHE_HOME:-$HOME/.cache}"/sxmo
# shellcheck disable=SC2034
export LOGDIR="${XDG_DATA_HOME:-$HOME/.local/share}"/sxmo/modem
# shellcheck disable=SC2034
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
# shellcheck disable=SC2034
export CONTACTFILE="$XDG_CONFIG_HOME/sxmo/contacts.tsv"
# shellcheck disable=SC2034
export MODEMSTATEFILE="$XDG_RUNTIME_DIR/sxmo.modem.state"
# shellcheck disable=SC2034
export UNSUSPENDREASONFILE="$XDG_RUNTIME_DIR/sxmo.suspend.reason"
# shellcheck disable=SC2034
export LASTSTATE="$XDG_RUNTIME_DIR/sxmo.suspend.laststate"

command -v "$KEYBOARD" > /dev/null || export KEYBOARD=svkbd-mobile-intl
command -v "$EDITOR" > /dev/null || export EDITOR=vis

# This script ensures all sxmo scripts are using the busybox version of
# certain coreutils rather than any other version that may be installed on the
# user's computer

#aliases aren't expanded in bash
# shellcheck disable=SC2039,SC3044
command -v shopt > /dev/null && shopt -s expand_aliases

alias dmenu="sxmo_dmenu.sh"
alias jq="gojq" # better performances

alias find="busybox find"
# Use native commands if busybox was compile without those apples (for example Debians busybox)
if busybox pkill -l > /dev/null; then
	alias pkill="busybox pkill"
	alias pgrep="busybox pgrep"
fi
alias xargs="busybox xargs"
alias less="busybox less"
alias tail="busybox tail"
alias grep="busybox grep"

SXMO_COMMON_INCLUDED=1

# shellcheck disable=SC2034
icon_chk="[x]" #we override this later if the user wants icons
# shellcheck disable=SC2034
icon_wif="W" #we override this later if the user wants icons

[ "$SXMO_NO_ICONS" = "1" ] && return 0;

#this script is meant to be sourced
#the glyphs are often in the private use area and
#therefore require a font like those in https://github.com/ryanoasis/nerd-fonts/ for proper display

# shellcheck disable=SC2034
icon_itm="" #item (default)
# shellcheck disable=SC2034
icon_trm='' #terminal
# shellcheck disable=SC2034
icon_vim=''
# shellcheck disable=SC2034
icon_tgm='' #telegram
# shellcheck disable=SC2034
icon_gps='' #gps
# shellcheck disable=SC2034
icon_msg="" #text
# shellcheck disable=SC2034
icon_pwr="⏻" #power
# shellcheck disable=SC2034
icon_cfg="" #configuration cog
# shellcheck disable=SC2034
icon_cls="" #close
# shellcheck disable=SC2034
icon_phn="" #phone
# shellcheck disable=SC2034
icon_dir="" #directory folder
# shellcheck disable=SC2034
icon_fil="" #file
# shellcheck disable=SC2034
icon_grd=""
# shellcheck disable=SC2034
icon_mnu=""
# shellcheck disable=SC2034
icon_cam=""
# shellcheck disable=SC2034
icon_net=""
# shellcheck disable=SC2034
icon_bel=""
# shellcheck disable=SC2034
icon_mic=""
# shellcheck disable=SC2034
icon_mmc=""
# shellcheck disable=SC2034
icon_mus=""
# shellcheck disable=SC2034
icon_mut="" #mute
# shellcheck disable=SC2034
icon_spk="" #speaker
# shellcheck disable=SC2034
icon_img=""
# shellcheck disable=SC2034
icon_usr=""
# shellcheck disable=SC2034
icon_tmr="" #timer
# shellcheck disable=SC2034
icon_arl=""
# shellcheck disable=SC2034
icon_arr=""
# shellcheck disable=SC2034
icon_aru=""
# shellcheck disable=SC2034
icon_ard=""
# shellcheck disable=SC2034
icon_ac1=""
# shellcheck disable=SC2034
icon_ac2=""
# shellcheck disable=SC2034
icon_ac3=""
# shellcheck disable=SC2034
icon_ac4=""
# shellcheck disable=SC2034
icon_mov=""
# shellcheck disable=SC2034
icon_shr="" #shrink
# shellcheck disable=SC2034
icon_exp="" #expand
# shellcheck disable=SC2034
icon_zmi=""
# shellcheck disable=SC2034
icon_zmo=""
# shellcheck disable=SC2034
icon_hom=""
# shellcheck disable=SC2034
icon_rld=""
# shellcheck disable=SC2034
icon_hdp="" #headphones
# shellcheck disable=SC2034
icon_lck=""
# shellcheck disable=SC2034
icon_rss=""
# shellcheck disable=SC2034
icon_lnk=""
# shellcheck disable=SC2034
icon_cpy=""
# shellcheck disable=SC2034
icon_pst=""
# shellcheck disable=SC2034
icon_fnd="" #search/find
# shellcheck disable=SC2034
icon_win="" #window
# shellcheck disable=SC2034
icon_tab=""
# shellcheck disable=SC2034
icon_flt="" #filter/pipe
# shellcheck disable=SC2034
icon_glb="" #globe
# shellcheck disable=SC2034
icon_phl="" #phonelog
# shellcheck disable=SC2034
icon_inf="" #info
# shellcheck disable=SC2034
icon_fll="" #flashlight
# shellcheck disable=SC2034
icon_clk=""
# shellcheck disable=SC2034
icon_rol="" #rotate left
# shellcheck disable=SC2034
icon_ror="" #rotate right
# shellcheck disable=SC2034
icon_upc="" #up in circle
# shellcheck disable=SC2034
icon_zzz="" #sleep/suspend/crust
# shellcheck disable=SC2034
icon_out="" #logout
# shellcheck disable=SC2034
icon_ytb="" #youtube
# shellcheck disable=SC2034
icon_wtr="" #weather
# shellcheck disable=SC2034
icon_red="" #reddit
# shellcheck disable=SC2034
icon_vid="" #video
# shellcheck disable=SC2034
icon_mvi="" #movie
# shellcheck disable=SC2034
icon_clc="" #calculator
# shellcheck disable=SC2034
icon_eml="" #email
# shellcheck disable=SC2034
icon_edt="" #editor
# shellcheck disable=SC2034
icon_ffx="" #firefox
# shellcheck disable=SC2034
icon_ffw="'" #fast forward
# shellcheck disable=SC2034
icon_fbw=""
# shellcheck disable=SC2034
icon_pau=""
# shellcheck disable=SC2034
icon_a2y="⇅"
# shellcheck disable=SC2034
icon_a2x="⇄"
# shellcheck disable=SC2034
icon_sav="" #save
# shellcheck disable=SC2034
icon_ret="" #return
# shellcheck disable=SC2034
icon_nxt="" #next
# shellcheck disable=SC2034
icon_prv="" #previous
# shellcheck disable=SC2034
icon_stp="" #stop
# shellcheck disable=SC2034
icon_sfl="" #shuffle, random
# shellcheck disable=SC2034
icon_lst="" #list
# shellcheck disable=SC2034
icon_kbd="" #keyboard
# shellcheck disable=SC2034
icon_del="﫧" #delete
# shellcheck disable=SC2034
icon_grp="" #group
# shellcheck disable=SC2034
icon_snd="" #send
# shellcheck disable=SC2034
icon_phx="" #hangup
# shellcheck disable=SC2034
icon_wn2=""
# shellcheck disable=SC2034
icon_chk=""
# shellcheck disable=SC2034
icon_and=""
# shellcheck disable=SC2034
icon_wif=""
# shellcheck disable=SC2034
icon_bth=""
# shellcheck disable=SC2034
icon_pls=""
# shellcheck disable=SC2034
icon_key=""
# shellcheck disable=SC2034
icon_bok=""
# shellcheck disable=SC2034
icon_map=""

#allow the user to override icons
# shellcheck disable=SC1091
[ -x "$XDG_CONFIG_HOME/sxmo/hooks/icons" ] && . "$XDG_CONFIG_HOME/sxmo/hooks/icons"