-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy path_tos
More file actions
510 lines (442 loc) · 12.7 KB
/
Copy path_tos
File metadata and controls
510 lines (442 loc) · 12.7 KB
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
#compdef _tos tos
_tos_subcommands() {
local commands; commands=(
'-iso:Install TOS onto your system'
'-S:Install a package'
'-R:Remove a package'
'-Q:Query package database'
{-h,--help}":Show help imformation" \
{-p,--profile}":Set your profile picture" \
{c,calamares}":Install TOS using a normal installer" \
{i,installer}":Install tos via a material themed GUI installer" \
{is,installer-server}":Install tos from the terminal" \
{-u,--update}":Update the system to the latest version" \
{-c,--crypto}":Add a ssh key, when a user@ip is specified add current key to that host" \
{-rs,--repair-system}":Perform a system repair (this will take a long time)" \
{gpg,g}": Show pgp (Gnu pg) related commands"\
{network,n}": Show network related commands"\
{theme,t}": Show theme related commands"\
{bluetooth,b}": Show bluetooth related commands"\
{volume,v}": Show volume related commands"\
{screen,s}": Show screen related commands"\
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_subcommands' \
'*::arg:->args'
case $line[1] in
"-iso")
_tos_install_graphical
;;
"-S"*)
_tos_S_install
;;
"-R"*)
_tos_R_remove
;;
"-Q"*)
_tos_Q_query
;;
"-p"|"--profile")
_tos_profile_picture
;;
"g"|"gpg")
_tos_gpg
;;
"n"|"network")
_tos_network
;;
"t"|"theme")
_tos_theme
;;
"b"|"bluetooth")
_tos_bluetooth
;;
"v"|"volume")
_tos_volume
;;
"s"|"screen")
_tos_screen
;;
esac
}
_tos_gpg_subcommands() {
local commands; commands=(
{info,in}": Get general information"
{key,k}": List all keys"
{export,e}": Export a key to a file"
{import,i}": Import a key from a file"
{upload,u}": Upload a key to a keyserver"
{generate,ge}": Generate a gpg key"
{git,gi}": Add a gpg key to your git config"
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos_gpg {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_gpg_subcommands' \
'*::arg:->args'
case $line[1] in
"export"|"e")
_tos_gpg_key
;;
"upload"|"u")
_tos_gpg_key
;;
"git"|"gi")
_tos_gpg_key
;;
"import"|"i")
_tos_gpg_file
;;
esac
}
function _tos_gpg_key() {
list=$(tos gpg key)
_arguments -C\
"1: :($list)"\
}
_tos_network_subcommands() {
local commands; commands=(
{metric,m}": Show the metric of an interface"
{device,d}": Show the network devices"
{restart,r}": Restart the network stack"
{connect,c}": Connect to a wireless network"
{list,l}": List the network interfaces"
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos_network {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_network_subcommands' \
'*::arg:->args'
case $line[1] in
"m"|"metric")
_tos_metric
;;
"c"|"connect")
_tos_wifi_connect
;;
esac
}
_tos_theme_subcommands() {
local commands; commands=(
{set,s}": Set the theme"
{add,a}": Add a theme to the database"
{delete,d}": Delete a theme"
{random,r}": enable or disable a theme"
{list,l}": List database"
{time,t}": Set the time"
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos_theme {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_theme_subcommands' \
'*::arg:->args'
case $line[1] in
"s"|"set")
_tos_change_theme
;;
"a"|"add")
_tos_add_theme
;;
"d"|"delete")
_tos_delete_theme
;;
"r"|"random")
_tos_random_theme
;;
esac
}
_tos_bluetooth_subcommands() {
local commands; commands=(
{set,s}": Enable or disable bluetooth"
{list,l}": List all bluetooth devices (add scan option to enable scanning"
{connect,c}": Connect to a bluetooth device"
{disconnect,d}": Disconnect from a bluetooth device"
{pair,p}": Pair with a device"
{full,f}": Go into full interactive mode"
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos_bluetooth {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_bluetooth_subcommands' \
'*::arg:->args'
case $line[1] in
"c"|"connect")
_tos_blue_connect
;;
"d"|"disconnect")
_tos_blue_disconnect
;;
"p"|"pair")
_tos_blue_pair
;;
esac
}
_tos_screen_subcommands() {
local commands; commands=(
{get,g}": Get information about current screen config"
{add,a}": Add a new resolution config to the screen modes"
{duplicate,d}": Duplicate your screen"
{dpi,dp}": Change the dpi/scaling of your screen"
{toggle,t}": Turn screen on or off"
{reset,r}": Reset screen to original version"
{res,resolution}": Change resolution"
{rate,refresh}": Change refresh rate"
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos_screen {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_screen_subcommands' \
'*::arg:->args'
case $line[1] in
"d"|"duplicate")
_tos_screen_duplicate
;;
"dp"|"dpi")
_tos_screen_dpi
;;
"a"|"add")
_tos_screen_add
;;
"t"|"toggle")
_tos_screen_toggle
;;
"r"|"reset")
_tos_screen_select
;;
"res"|"resolution")
_tos_screen_res
;;
"rate"|"refresh")
_tos_screen_refresh_rate
;;
esac
}
_tos_volume_subcommands() {
local commands; commands=(
{get,g}": Get the current audio config"
{c,change}": Change the volume in percentage"
{set,s}": Set the current volume in percentage"
{toggle,t}": toggle the volume"
)
_describe -t commands 'subcommands' commands "$@"
}
function _tos_volume {
local context curcontext="$curcontext" state line
typeset -A opt_args
local ret=1
_arguments -C \
'1: :_tos_volume_subcommands' \
'*::arg:->args'
}
function _tos_gpg_file {
_arguments -C\
'*:keys:_files -g "*"'\
}
function _tos_screen_toggle {
list=$(xrandr | awk '$1 !~ /Screen|[0-9]*x[0-9]*/ {print $1}')
_arguments -C\
"1: :($list)"\
"2: :(on off)"\
}
function _tos_screen_refresh_rate {
list=$(xrandr | awk '$1 !~ /Screen|[0-9]*x[0-9]*/ {print $1}')
local line
_arguments -C\
"1: :($list)"\
"*::arg:->args"
_tos_find_rate $line[1]
}
function _tos_screen_res {
list=$(xrandr | awk '$1 !~ /Screen|[0-9]*x[0-9]*/ {print $1}')
local line
_arguments -C\
"1: :($list)"\
"*::arg:->args"
_tos_find_res $line[1]
}
function _tos_screen_add {
list=$(xrandr | awk '$1 !~ /Screen|[0-9]*x[0-9]*/ {print $1}')
local line
_arguments -C\
"1: :($list)"\
"*::arg:->args"
_tos_find_res $line[1]
}
function _tos_find_rate {
list=$(xrandr | awk -v monitor="^"$1" connected" '/connected/ {p = 0}$0 ~ monitor {p = 1}p' | sed 's/^'$1'.*$//g' | awk '{print $2}' | sed 's/*+//g')
_arguments -C\
"1: :($list)"\
"*::arg:->args"
}
function _tos_find_res {
list=$(xrandr | awk -v monitor="^"$1" connected" '/connected/ {p = 0}$0 ~ monitor {p = 1}p' | sed 's/^'$1'.*$//g' | awk '{print $1}')
_arguments -C\
"1: :($list)"\
"*::arg:->args"
}
function _tos_screen_duplicate {
list=$(xrandr | awk '$1 !~ /Screen|[0-9]*x[0-9]*/ {print $1}')
local line
_arguments -C\
"1: :($list)"\
"*::arg:->args"
_tos_screen_select
}
function _tos_screen_dpi {
_tos_screen_select
}
function _tos_screen_select {
list=$(xrandr | awk '$1 !~ /Screen|[0-9]*x[0-9]*/ {print $1}')
_arguments -C\
"1: :($list)"
}
function _tos_blue_connect {
_tos_blue_list_available
}
function _tos_blue_disconnect {
_tos_blue_list_available
}
function _tos_blue_pair {
_tos_blue_list_available
}
function _tos_blue_list_available {
list=$(bluetoothctl devices | awk '{print "\""$0"\"" }' | sed -E 's/Device ([0-9ABCDEF]{2}:)*[0-9ABCDEF]{2} //g')
_arguments -C\
"1: :($list)"
}
function _tos_profile_picture {
_arguments -C\
'*:Images:_files -g "*.jpg|*.png|*.jpeg"'\
}
function _tos_add_theme {
_arguments -C\
'*:Images:_files -g "*.jpg|*.png|*.jpeg"'\
}
function _tos_delete_theme {
list=$(awk '$0 ~ /^.*\.png|^.*\.jpg|^.*\.jpeg/{print $0}' ~/.config/tos/theme | sed '/^#/d')
_arguments -C\
"1: :($list)"
}
function _tos_random_theme {
_arguments -C\
"1: :(on off)"
}
function _tos_change_theme {
_arguments -C\
'*:Images:_files -g "*.jpg|*.png|*.jpeg"'\
}
function _tos_wifi_connect {
list=$(nmcli d wifi list | awk '$1 !~ /IN-USE|*/{print $0}' | grep -Eo '^.* Infra' | sed 's/Infra//' | awk '{print "\""$0"\""}' | sed -r -e 's/^\"\s+/\"/g' -e 's/\s*\"/\"/g')
_arguments -C\
"1: :($list)"
}
function _tos_metric {
list=$(ip link show up | awk '$1 ~ /[0-9]*:.*/{printf $2}' | tr ':' ' ')
_arguments -C \
"1: :($list)"
}
function _tos_install_graphical {
_arguments \
"-g[Install with a gui (Omit if you want a text based installer)]"
}
function _tos_install_package {
local line
_arguments -C -s\
"1: :(-S -R)" \
"*::arg:->args"
case $line[1] in
"-S"*)
_tos_S_install
;;
"-R"*)
_tos_R_remove
;;
esac
}
function _tos_S_install {
_arguments -s \
"-yu[Sync and update database]"\
"-yyu[Force download database and sync with remote repo's]"\
"-y[Sync databases with remote repo]" \
"-yy[force reload with remote repo]" \
"-a[Assume targets are from the AUR]" \
"-b[Alternative database localation]" \
"-c[Remove old packages from the cache]" \
"-d[Skip dependency cheks]" \
"-g[View all members of a package group]" \
"-h[Display syntax for the fiven operation]" \
"-i[View package information]" \
"-l[List all packages in a repo]" \
"-p[Prind download URI's for each package]" \
"-q[Show less info about queries and searches]" \
"-r[Set alternative install root]" \
"-s[Search package names and descrptions]" \
"-u[Upgrade all out-of-date packages]" \
"-v[Be more verbose]" \
"-w[Download packages only]" \
"-s[search for a package]"\
}
function _tos_R_remove {
_arguments -s \
"-ns[Remove packages with all its dependencies and config files]" \
"-a[Assume targets are from the AUR]" \
"-b[Alternate database location]" \
"-c[Remove all dependent packages]" \
"-d[Skip dependency checks]" \
"-h[Display syntaxt for a given operation]" \
"-n[Remove protected configuration files]" \
"-p[Only print the targets instead of perfomring the operation]" \
"-r[Set alternative installation root]" \
"-s[Remove dependencies not required by other packages]" \
"-u[Remove unneeded packages]" \
"-v[Be more verbose]"
}
function _tos_Q_query {
_arguments -s \
"-a[Assume targets are from the AUR]" \
"-b[Alternate database location]" \
"-c[List package changelog]" \
"-d[List packages installed as dependencies]" \
"-e[List packages explicitly installed]" \
"-g[View all members of a package group]" \
"-h[Display syntax for the given operation]" \
"-i[View package info]" \
"-k[Check package files]" \
"-l[List package contents]" \
"-m[List installed packages not found in sync db(s)]" \
"-n[List installed packages found in sync db(s)]" \
"-o[Query the package that owns a file]" \
"-p[Package file to query]" \
"-q[Show less information for query and search]" \
"-r[Set alternate installation root]" \
"-s[Search package names and descriptions]" \
"-t[list packages not required by other packages]" \
"-u[List packages that can be upgraded]" \
"-v[Be more verbose]" \
}