-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsettings.sh
executable file
·1605 lines (1475 loc) · 42.3 KB
/
settings.sh
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# graphical settings menu for instantOS
source /usr/share/instantsettings/utils/functions.sh
[ -r ./utils/functions.sh ] && source ./utils/functions.sh
# access specific settings page from external script
if [ "$1" = "-s" ] && [ -z "$SCRIPTSETTINGS" ]; then
if [ -z "$2" ]; then
echo "usage: instantsettings -s settingspage"
fi
export SCRIPTSETTINGS="true"
source /usr/bin/instantsettings
eval "$2"
exit
fi
if iconf settingsposition; then
SIDEBARPOS="$(iconf settingsposition)"
export SIDEBARPOS
fi
asksetting() {
menu '>>h Settings | ⌘ + Ctrl + C'
menu ':y SEARCH ALL' #
menu ':b instantOS'
menu ':b 墳Sound'
menu ':b Display'
menu ':g Network'
menu ':b Install Software'
menu ':b Bluetooth'
menu ':y Appearance'
menu ':b Keyboard'
menu ':b Mouse'
menu ':b Default applications'
menu ':g Power'
menu ':b Users'
menu ':b Language'
menu ':g Time and date'
menu ':b File types'
menu ':b 朗Printing'
menu ':r Storage'
menu ':y Advanced'
menu ':r Close Settings'
SIDEBARSEARCH="${SIDEBARSEARCH:-SEARCH ALL}"
export SIDEBARINDEX=0
meta asksetting menu | sidebar "Search categories"
unset SIDEBARINDEX
}
# Variables for global settings search
declare -A allsettings
export SIDEBARSEARCH=
export CFG_CACHE="${XDG_CACHE_HOME:-~/.cache}/instantos/allsettings.bash"
[ -r "$CFG_CACHE" ] && source -- "$CFG_CACHE"
filter_entries() {
typeset funcname="$1"
# Filter out a few things
FUNCTIONTITLE="$(
meta "$funcname" menu | grep '>>h ' | sed 's/^....//g'
)"
meta "$funcname" menu |
grep -vE "^(>>h|>h)" |
grep -vE "(Apply|Back|Custom|Yes|No|Close|Close Settings|permanent|Edit|Reset|ALL)$" |
sed 's/^\(....\)\(.*\)/\1'"$FUNCTIONTITLE"' \2/g'
}
searchall() {
if [ ${#allsettings[*]} -eq 0 ]; then
for funcname in $(list_func_names); do
OLDIFS="$IFS"
IFS=$'\n'
for entry in $(filter_entries "$funcname"); do
allsettings["$entry"]="$funcname"
done
IFS="$OLDIFS"
done
declare -p allsettings >"$CFG_CACHE" 2>/dev/null
fi
export SIDEBARINDEX=0
CHOICE=$(printf '%s\n' "${!allsettings[@]}" | sidebar)
unset SIDEBARINDEX
if [ -z "$CHOICE" ]; then
LOOPSETTING=true
return
fi
SIDEBARSEARCH="${CHOICE:4}"
# clean up breadcrumbs
if grep -q "" <<<"$SIDEBARSEARCH"; then
SIDEBARSEARCH="$(sed 's/^.*[ ]*//g' <<<"$SIDEBARSEARCH")"
fi
echo "choice ${allsettings["$CHOICE"]}"
if [ "${allsettings["$CHOICE"]}" = "asksetting" ]; then
LOOPSETTING=true
return
fi
export SIDEBARINDEX=0
"${allsettings["$CHOICE"]}"
unset SIDEBARINDEX
SIDEBARSEARCH=
}
soundsettings() {
menu '>>h Sound settings'
menu ':b ﰝSystem audio'
menu ':y Notification sound'
menu ':b Back'
CHOICE="$(meta soundsettings menu | sidebar)"
case "$CHOICE" in
*audio)
pavucontrol &
exit
;;
*sound)
notificationsettings
;;
*)
LOOPSETTING="True"
;;
esac
}
notificationsettings() {
menu '>>h Notification sound settings'
menu ':b Custom'
menu ':y 碑Reset'
menu ':r Mute'
CHOICE="$(meta notificationsettings menu | sidebar)"
case $CHOICE in
*Custom)
instantinstall zenity || return
SOUNDPATH="$(zenity --file-selection)"
if [ -z "$SOUNDPATH" ]; then
notificationsettings
return
fi
if ! mpv "$SOUNDPATH"; then
if ! echo "file $SOUNDPATH does not appear to be an audio file, use regardless ?" | imenu -C; then
exit
fi
fi
iconf -i nonotify 0
cp "$SOUNDPATH" ~/instantos/notifications/customsound
;;
*Reset)
iconf -i nonotify 0
rm ~/instantos/notifications/customsound
;;
*Mute)
toggleiconf nonotify "mute notification alert sounds"
;;
esac
}
defaultapplicationsettings() {
menu '>>h Default applications'
menu ':b Browser'
menu ':b 龍System monitor'
menu ':b Terminal emulator'
menu ':b File manager'
menu ':b Application launcher'
menu ':y Text editor'
menu ':r Lock screen'
menu ':r Terminal file manager'
menu ':b Back'
CHOICE="$(meta defaultapplicationsettings menu | sidebar)"
case "$CHOICE" in
*Terminal*manager)
selecttermfilemanager
;;
*manager)
selectfilemanager
;;
*Browser)
selectbrowser
;;
*emulator)
selectterminal
;;
*monitor)
selectsystemmonitor
;;
*launcher)
selectappmenu
;;
*editor)
selecteditor
;;
*screen)
selectlockscreen
;;
*)
LOOPSETTING="True"
;;
esac
if [ -z "$LOOPSETTING" ]; then
instantutils default
fi
}
# generic default app selector
selectapp() {
# usage: echo list | selectapp heading iconf-name
LIST=">>h Default $1
$(cat /dev/stdin)
:b Custom
:b Back"
CHOICE="$(echo "$LIST" | sidebar | sed 's/^....//g')"
echo "choice"
case "$CHOICE" in
none)
iconf -d "$2"
;;
Custom)
echo "setting custom application"
CUSTOMCHOICE="$(imenu -i "enter default $1")"
if ! command -v "$CUSTOMCHOICE"; then
if ! imenu -c "$CUSTOMCHOICE not found, still set as default $1?"; then
defaultapplicationsettings
return
fi
fi
iconf "$2" "$CUSTOMCHOICE"
;;
Back)
defaultapplicationsettings
;;
*)
LOWERCHOICE="$(echo "$CHOICE" | tr '[:upper:]' '[:lower:]')"
iconf "$2" "$LOWERCHOICE"
;;
esac
}
selectappmenu() {
selectdefault "appmenu" "Application launcher"
}
selectsystemmonitor() {
selectdefault "systemmonitor" "System Monitor"
}
selectfilemanager() {
selectdefault filemanager "File Manager" "inode/directory"
}
selecttermfilemanager() {
selectdefault termfilemanager "Terminal file Manager"
}
selectdefault() {
LIST=">>h Default ${2:-$1}
$(grep -o '^[^:][^:]*' /usr/share/instantsettings/data/default/"$1" | sed 's/^/:/g')
:b Custom
:b Back"
APPCHOICE="$(echo "$LIST" | sidebar | sed 's/^://g')"
if [ -z "$APPCHOICE" ]; then
defaultapplicationsettings
return 0
fi
case "$APPCHOICE" in
*Custom)
CUSTOMAPP="$(imenu -i "default $1")"
[ -z "$CUSTOMAPP" ] && return 1
iconf "$1" "$CUSTOMAPP \$@"
return 0
;;
*Back)
defaultapplicationsettings
return 0
;;
esac
APPID="$(grep "${APPCHOICE}:" /usr/share/instantsettings/data/default/"$1" | sed 's/^[^:]*://g')"
[ -z "$APPID" ] && return 1
echo "app id $APPID"
if [ -e /usr/share/instantsettings/data/default/defaultconfig/"$1"/"$APPID" ]; then
DEFAULTSETTING="$1"
getvalue() {
grep -i "^$1:" /usr/share/instantsettings/data/default/defaultconfig/"$DEFAULTSETTING"/"$APPID" | sed 's/^[^:]*://g'
}
SETCOMMAND="$(getvalue command)"
[ "$SETCOMMAND" ] || return 1
iconf "$1" "$SETCOMMAND"
PACKAGES="$(getvalue package)"
if [ -n "$PACKAGES" ]; then
if grep -q ',' <<<"$PACKAGES"; then
echo "multiple dependencies detected"
INSTALLLIST="$(sed 's/\,/ /g' <<<"$PACKAGES")"
for i in $(echo $INSTALLLIST); do
instantinstall "$i" || exit 1
done
else
instantinstall "$PACKAGES"
fi
if [ -n "$3" ]; then
XDGSETTING="$(getvalue xdg)"
[ -z "$XDGSETTING" ] && return
while read -r mime; do
echo "setting mime type $mime to $XDGSETTING"
xdg-mime default "$XDGSETTING.desktop" "$mime"
done <<<"$(sed 's/ /\n/g' <<<"$3")"
fi
fi
else
instantinstall "$APPID" || exit 1
iconf "$1" "$APPID"
return
fi
}
selectterminal() {
selectdefault "terminal" "Terminal emulator"
}
selectbrowser() {
selectdefault browser "Web Browser" "x-scheme-handler/http x-scheme-handler/https"
}
selecteditor() {
selectdefault editor "Text editor" 'text/plain'
}
selectlockscreen() {
selectdefault lockscreen "Lock Screen"
}
getmimetypes() {
grep -o '^[^=]*' /usr/share/applications/mimeinfo.cache | sort -u
}
mimesettings() {
FIRSTCHOICE="$(
{
echo ":b Show all"
grep -o '^:[^:]*' /usr/share/instantsettings/data/filetypes | grep '..'
} | sidebar
)"
[ -z "$FIRSTCHOICE" ] && exit
if [ "$FIRSTCHOICE" = ":b Show all" ]; then
echo 'editing manual mime options'
MIMETYPES="$(getmimetypes)"
MIMECHOICE="$(
echo "$MIMETYPES" | sidebar
)"
[ -z "$MIMECHOICE" ] && exit
else
MIMECHOICE="$(grep "$FIRSTCHOICE" /usr/share/instantsettings/data/filetypes | sed 's/^:[^:]*://g' | sed 's/:/\n/g')"
echo "MIME $MIMECHOICE"
fi
APPCHOICE="$(
cat /usr/share/applications/mimeinfo.cache | grep "^$(head -1 <<<"$MIMECHOICE")" | sed 's/^[^=]*=//g' | sed 's/;/\n/g' | grep '...' | sed 's/\.desktop$//g' | sidebar
)"
[ -z "$APPCHOICE" ] && exit
echo "setting $MIMECHOICE to open with $APPCHOICE"
while read -r mime; do
xdg-mime default "$APPCHOICE".desktop "$mime"
done <<<"$MIMECHOICE"
}
displaysettings() {
menu '>>h Display Settings'
menu ':b Change display settings'
menu ':g Make current settings permanent'
menu ':y Change screen brightness'
menu ':b Autodetect monitor docking'
menu ':b External screen'
menu ':b HiDPI'
menu ':b Keep screen on when locked'
CHOICE="$({
meta displaysettings menu
[ -e /usr/bin/nvidia-smi ] &&
echo ':g 來Nvidia'
echo ':b Back'
} | sidebar)"
case $CHOICE in
*settings)
arandr &
;;
*brightness)
/usr/share/instantassist/assists/b.sh
;;
*permanent)
notify-send "saving current monitor settings"
instantinstall autorandr || exit 1
autorandr --force --save instantos
;;
*screen)
instantdisper
;;
*docking)
toggleiconf autoswitch "auto detect new monitors being plugged in?"
if iconf -i autoswitch; then
instantinstall udevwait || {
iconf -i autoswitch 0
iconf -i noautoswitch 1
exit 1
}
iconf -i noautoswitch 0
else
iconf -i noautoswitch 1
fi
displaysettings
;;
*HiDPI)
if imenu -c "enable HiDPI"; then
DPI=$(imenu -i 'enter dpi (default is 96)')
[ -z "$DPI" ] && return
if ! [ "$DPI" -eq "$DPI" ] || [ "$DPI" -gt 500 ] || [ "$DPI" -lt "20" ]; then
imenu -m "please enter a number between 20 and 500 (default is 96)"
return
fi
iconf dpi "$DPI"
else
iconf -d dpi
fi
instantdpi
xrdb ~/.Xresources
;;
*locked)
toggleiconf nolocktimeout "keep monitor on when the screen is locked?"
displaysettings
;;
*Nvidia)
instantinstall nvidia-settings || exit 1
nvidia-settings
exit
;;
*)
LOOPSETTING="True"
;;
esac
}
advancedsettings() {
menu '>>h Advanced settings'
menu ':b Firewall'
menu ':y TLP'
menu ':g Bootloader'
menu ':b Pacman cache autoclean'
menu ':b 力Systemd'
menu ':b Firmware'
menu ':b Lightdm'
menu ':b Back'
CHOICE="$(meta advancedsettings menu | sidebar)"
case $CHOICE in
*Firewall)
instantinstall gufw || exit 1
gufw &
;;
*TLP)
instantinstall tlpui || exit 1
tlpui &
;;
*Bootloader)
instantinstall grub-customizer || exit 1
grub-customizer &
;;
*Pacman*cache*autoclean)
instantinstall pacman-contrib || exit 1
if imenu -c 'Enable weekly autoclean pacman cache?'; then
instantsudo bash -c 'sed -e "s;paccache -r;paccache -rk3 -ruk1;g" /usr/lib/systemd/system/paccache.service | tee /usr/lib/systemd/system/instantpaccache.service; cp /usr/lib/systemd/system/paccache.timer /usr/lib/systemd/system/instantpaccache.timer; systemctl daemon-reload; systemctl enable --now instantpaccache.timer'
else
instantsudo systemctl disable --now instantpaccache.timer
fi
;;
*Systemd)
instantinstall cockpit chromium || exit 1
if ! systemctl is-enabled cockpit.socket; then
instantsudo systemctl enable --now cockpit.socket || exit 1
sleep 4
imenu -m "sign in with $(whoami) in the next window"
fi
chromium --app="http://localhost:9090" &
exit
;;
*Firmware)
instantinstall gnome-firmware || exit 1
gnome-firmware &
;;
*Lightdm)
instantinstall lightdm-gtk-greeter-settings || exit 1
pkexec lightdm-gtk-greeter-settings
exit
;;
*)
LOOPSETTING="True"
;;
esac
}
wallpapersettings() {
menu '>>h Wallpaper settings'
menu ':b Generate new wallpaper'
menu ':b Set own wallpaper'
menu ':b Browse wallpapers'
menu ':b Custom wallpaper with logo'
menu ':b Logo'
menu ':b Repair wallpaper'
menu ':b Colored wallpaper'
menu ':b Export current wallpaper'
menu ':b Back'
CHOICE="$(meta wallpapersettings menu | sidebar)"
case $CHOICE in
*Generate*)
instantwallpaper clear && instantwallpaper w
;;
*Export*)
if [ -e ~/instantos/wallpapers/instantwallpaper.png ]; then
instantinstall zenity || return
SAVEPATH="$(zenity --file-selection --save --confirm-overwrite)"
if [ -n "$SAVEPATH" ]; then
cp ~/instantos/wallpapers/instantwallpaper.png "$SAVEPATH"
exit
else
wallpapersettings
return
fi
else
imenu -m "no instantwallpaper set"
wallpapersettings
return
fi
;;
*Browse*)
instantwallpaper select &
;;
*Colored*)
coloredwallsettings
;;
*Repair*)
rm ~/instantos/wallpapers/*.png
rm ~/instantos/wallpapers/default
instantmonitor
instantwallpaper
;;
*wallpaper)
instantwallpaper gui &
;;
*Logo)
toggleiconf nologo "show logo on wallpaper?" i
wallpapersettings
;;
*logo)
instantwallpaper logo
;;
*)
appearancesettings
return
;;
esac
}
coloredwallsettings() {
menu '>>h Colored wallpaper'
menu ':b Use colored wallpaper'
menu ':b Foreground color'
menu ':b Background color'
menu ':b Back'
CHOICE="$(meta coloredwallsettings menu | sidebar)"
instantinstall zenity || return
askcolor() {
RETCOLOR="$(zenity --color-selection)"
[ -z "$RETCOLOR" ] && return 1
printf "#%02x%02x%02x\n" $(grep -o '[0-9,]*' <<<"$RETCOLOR" | sed 's/,/ /g')
}
refreshwall() {
if iconf -i coloredwallpaper; then
echo "refreshing colored wallpaper"
notify-send 'generating colored wallpaper'
{
instantwallpaper color "$(iconf fgcolor:\#ffffff)" "$(iconf bgcolor:\#00000)"
instantwallpaper set ~/instantos/wallpapers/color/customcolor.png
} &
else
imenu -m 'Colored wallpaper is currently disabled. Your settings will not take effect until you enable it'
fi
}
case "$CHOICE" in
*wallpaper)
toggleiconf coloredwallpaper "use solid colors as wallpaper?"
if iconf -i coloredwallpaper; then
[ -e ~/instantos/wallpapers/color/customcolor.png ] || instantwallpaper color "$(iconf fgcolor:\#ffffff)" "$(iconf fgcolor:\#00000)"
refreshwall
else
instantwallpaper clear
fi
coloredwallsettings
return
;;
*Foreground*)
FGCOLOR="$(askcolor)"
if [ -n "$FGCOLOR" ]; then
iconf fgcolor "$FGCOLOR"
else
return
fi
refreshwall
coloredwallsettings
return
;;
*Background*)
BGCOLOR="$(askcolor)"
if [ -n "$BGCOLOR" ]; then
iconf bgcolor "$BGCOLOR"
else
return
fi
refreshwall
coloredwallsettings
return
;;
*)
echo "going back"
wallpapersettings
return
;;
esac
}
networksettings() {
menu '>>h Network settings'
menu ':b Start network applet'
menu ':g Autostart network applet'
menu ':b IP info'
menu ':b 龍Test internet speed'
menu ':b Back'
CHOICE="$(meta networksettings menu | sidebar)"
case "$CHOICE" in
*Autostart*)
toggleiconf wifiapplet "Show network applet on startup?"
if iconf -i wifiapplet; then
pgrep nm-applet || nm-applet
else
pgrep nm-applet && pkill nm-applet
fi
networksettings
;;
*Start*)
pgrep nm-applet || nm-applet &
;;
*info)
getlocalip() {
TEMPIP="$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')"
if grep -q '192' <<<"$TEMPIP"; then
echo "$TEMPIP" | grep '192' | tail -1
else
echo "$TEMPIP" | tail -1
fi
}
if getlocalip; then
LOCALIP="$(getlocalip)"
fi
if checkinternet; then
PUBLICIP="$(curl ifconfig.me)"
fi
if [ -z "${PUBLICIP}${LOCALIP}" ]; then
imenu -e "error getting network information"
exit
fi
CHOICE="$(echo "public ip: ${PUBLICIP:-not found}
local ip: ${LOCALIP:-not found}
OK" | imenu -l "Network info")"
if grep -q 'not found' <<<"$CHOICE" || ! grep -q 'ip' <<<"$CHOICE"; then
exit
fi
echo "$CHOICE" | grep -o '[^:]*$' | grep -o '[^ ]*' | head -1 | xclip -selection c
notify-send "copied ip to clipboard"
exit
;;
*speed)
instantspeedtest
;;
*)
LOOPSETTING="True"
;;
esac
}
# the language settings reuse instantARCH components
fetchlanguage() {
if ! [ -e ~/.cache/instantARCH ]; then
if ! checkinternet; then
imenu -e "internet not found, couldn't fetch language list"
exit 1
fi
imenu -w "Preparing language settings"
cd ~/.cache || die "no cache"
git clone --depth=1 https://github.com/instantOS/instantARCH
pkill imenu
pkill instantmenu
else
cd ~/.cache/instantARCH || die "cache error"
if ! [ -e askutils.sh ]; then
cd ..
rm -rf instantARCH
if imenu -c "language cache invalid, reload?"; then
fetchlanguage
else
exit 1
fi
fi
git reset --hard
git pull &
fi
cd ~/.cache/instantARCH || die "cache error"
mkdir bin
cat iroot.sh >bin/iroot
chmod +x ./bin/iroot
export PATH="$PATH:~/.cache/instantARCH/bin"
mkdir -p ~/.config/instantos/iroot
IROOT="$(realpath ~/.config/instantos/iroot)"
export IROOT
INSTANTARCH="$(realpath ~/.cache/instantARCH)"
export INSTANTARCH
source askutils.sh
}
choosenumber() {
NUMCHOICE="$({
echo "$1"
seq 1 "$2" | tac
} | sidebar "Change $3")"
[ -n "$NUMCHOICE" ] && [ "$NUMCHOICE" -eq "$NUMCHOICE" ] && echo "$NUMCHOICE"
}
timesettings() {
echo "changing time/date"
printf -v YEAR '%(%Y)T' -1
printf -v MONTH '%(%m)T' -1
printf -v DAY '%(%d)T' -1
printf -v HOUR '%(%H)T' -1
printf -v MINUTE '%(%M)T' -1
while :; do
DATECHOICE="$(echo ">>h Change date
Auto detect
Year $YEAR
Month $MONTH
Day $DAY
Hour $HOUR
Minute $MINUTE
:g Apply
:b 12-hour clock
:b Back" | sidebar)"
echo "datechoice $DATECHOICE"
case "$DATECHOICE" in
*detect)
if imenu -c 'auto detect time?'; then
instantsudo systemctl enable --now systemd-timesyncd
else
instantsudo systemctl disable --now systemd-timesyncd
fi
;;
Day*)
NEWDAY="$(choosenumber "$DAY" 31 "day")"
DAY="${NEWDAY:-"$DAY"}"
;;
Year*)
NEWYEAR="$(choosenumber "$YEAR" 2100 "year")"
YEAR="${NEWYEAR:-"$YEAR"}"
;;
Hour*)
NEWHOUR="$(choosenumber "$HOUR" 24 "hour")"
HOUR="${NEWHOUR:-"$HOUR"}"
;;
Minute*)
NEWMINUTE="$(choosenumber "$MINUTE" 60 "minute")"
MINUTE="${NEWMINUTE:-"$MINUTE"}"
;;
Month*)
NEWMONTH="$(choosenumber "$MONTH" 12 "month")"
MONTH="${NEWMONTH:-"$MONTH"}"
;;
*Apply)
echo "changing date to $YEAR-$MONTH-$DAY $HOUR:$MINUTE:$(date +%S)"
if systemctl is-enabled systemd-timesyncd; then
instantsudo systemctl disable --now systemd-timesyncd
fi
instantsudo timedatectl set-time "$YEAR-$MONTH-$DAY $HOUR:$MINUTE:$(date +%S)"
;;
*clock)
toggleiconf 12hclock "enable 12-hour clock?"
;;
*)
LOOPSETTING="True"
return
;;
esac
done
}
languagesettings() {
menu '>>h Language settings'
menu ':b Application Language'
menu ':g Timezone'
menu ':b Back'
fetchlanguage
CHOICE="$(meta languagesettings menu | sidebar)"
case "$CHOICE" in
*Language)
echo "changing language"
asklocale
instantsudo INSTANTARCH="$INSTANTARCH" IROOT="$IROOT" PATH="$PATH" "$INSTANTARCH/lang/locale.sh"
if echo "some settings are only applied after a reboot
Reboot now?" | imenu -C; then
reboot
fi
;;
*Timezone)
askregion
echo "changing timezone"
instantsudo INSTANTARCH="$INSTANTARCH" IROOT="$IROOT" PATH="$PATH" "$INSTANTARCH/lang/timezone.sh"
;;
*)
LOOPSETTING="True"
;;
esac
}
toggleiconf() {
if [ -z "$3" ]; then
if iconf -i "$1"; then
CONFSTATUS="enabled"
else
CONFSTATUS="disabled"
fi
else
if iconf -i "$1"; then
CONFSTATUS="disabled"
else
CONFSTATUS="enabled"
fi
fi
unset SIDEBARSEARCH
CONFPROMPT=">>h $2
> Currently $CONFSTATUS
:g Yes
:r No
:b Back"
CHOICE=$(echo "$CONFPROMPT" | sidebar "choose answer" | grep -o '[^ ]*$')
case $CHOICE in
*Yes)
if [ -z "$3" ]; then
iconf -i "$1" 1
else
iconf -i "$1" 0
fi
;;
*No)
if [ -z "$3" ]; then
iconf -i "$1" 0
else
iconf -i "$1" 1
fi
;;
esac
}
instantossettings() {
menu '>>h instantOS settings'
menu ':b Edit Autostart script'
menu ':b Edit Session Environment'
menu ':b Edit Startup Applications'
menu ':y Potato'
menu ':b 𧻓Animations'
menu ':b ﰪConky Widgets'
menu ':b Desktop icons'
menu ':b ﰪDefault layout'
menu ':b Status bar'
menu ':b Clipboard manager'
menu ':b Alttab menu'
menu ':b Dad joke on lock screen'
menu ':b Autologin'
menu ':g Neovim preconfig'
menu ':r instantOS development tools'
menu ':b Settings position'
menu ':b Back'
CHOICE="$(meta instantossettings menu | sidebar)"
case $CHOICE in
*Autostart*)
if ! [ -e ~/.config/instantos/autostart.sh ]; then
mkdir -p ~/.config/instantos
if [ -e ~/.instantautostart ]; then
cat ~/.instantautostart >~/.config/instantos/autostart.sh
else
echo "# instantOS autostart script
# This script gets executed when $(whoami) logs in
# Add & (a literal) ampersand to the end of a line to make it run in the background" >~/.config/instantos/autostart.sh
fi
fi
instantutils open editor ~/.config/instantos/autostart.sh &
;;
*Environment)
if ! [ -e ~/.instantsession ]; then
echo "# instantOS Session Environment Script
# This script gets sourced when $(whoami) logs in
# Add environment variables that should be available to all processes executed from your desktop session." >~/.instantsession
fi
instantutils open editor ~/.instantsession &
;;
*Applications)
lxsession-edit
;;
*bar)
toggleiconf nostatus "enable default status text?" i
if iconf -i nostatus; then
[ -e ~/.instantsilent ] || touch ~/.instantsilent
xsetroot -name '^f11^ xsetroot -name "yourtext"'
else
[ -e ~/.instantsilent ] && rm ~/.instantsilent
fi &
instantossettings
;;
*manager)
toggleiconf clipmanager "Enable clipboard manager"
if ! iconf -i clipmanager; then
pgrep -f clipmenud && pkill -f clipmenud
else
instantinstall clipmenu || exit 1
pgrep -f clipmenud || clipmenud &
fi
instantossettings
;;
*Potato)
toggleiconf potato "do you consider this pc a potato?
> this disables multiple effects
> in order to improve performance
> on weak machines, this won't
> help much on faster machines
>>h --------"
instantossettings
;;
*Autologin)
if iconf -i noautologin; then
LOGINCHANGE="true"
fi
toggleiconf noautologin "Do you want to automatically log in on boot?" i
if [ -n "$LOGINCHANGE" ]; then
if ! iconf -i noautologin; then
LOGINUSER="$(imenu -i "automatically log in as" "username" "$(whoami)")"
if [ -z "$LOGINUSER" ]; then
exit
fi
if ! id "$LOGINUSER"; then
imenu -e "user $LOGINUSER does not exist"
iconf -i noautologin 1
exit 1
fi
if grep -q '^autologin-user' /etc/lightdm/lightdm.conf; then
instantsudo sed -i "s/^autologin-user=.*/autologin-user=$LOGINUSER/g" /etc/lightdm/lightdm.conf
else
instantsudo sed -i "s/^\[Seat:\*\]/[Seat:*]\nautologin-user=$LOGINUSER/g" /etc/lightdm/lightdm.conf
fi