Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
2181 lines (2066 loc) · 113 KB
/
Copy pathinstall.sh
File metadata and controls
2181 lines (2066 loc) · 113 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
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
# MacShell installer / updater
#
# git clone https://github.com/0-ss/MacShell && cd MacShell
# ./install.sh (installs exactly what is in the clone)
# ./install.sh --gui (same, in the graphical installer)
#
# What it does
# 1. checks every tool, library, QML module, font and service MacShell / MacLock need and installs the missing ones
# (pacman, dnf or apt; packages the main repositories lack come from the AUR / the Fedora COPR, and on Arch it can
# even set up an AUR helper for you). It also enables the bluetooth service, which Bluetooth needs.
# In a Hyprland session on Arch it offers to open the graphical installer (MacInstaller) instead of installing in the terminal.
# 2. downloads the latest release (or the latest commit of the main branch)
# 3. installs the shell to ~/.config/quickshell/MacShell (start it with: qs -c MacShell)
# the lock screen to ~/.config/quickshell/MacLock (lock with: sh ~/.config/quickshell/MacLock/lock-via-ipc.sh)
# (MacShell and MacLock are two separate Quickshell configs; neither is placed inside the other)
# the helper tree to ~/.config/hypr-macshell (scripts/ = Game Mode, video wallpapers, AirDrop, lock helper;
# plus the standalone Hyprland session config, hypridle / hyprlock files;
# your own custom/ folder is never overwritten)
# app launchers to ~/.local/share/applications (Finder, Photos, Clock ... entries for macshell-*.desktop)
# icons to ~/.local/share/icons/hicolor/scalable/apps
# the Apple emoji font rule to ~/.config/fontconfig/conf.d
# sounds to ~/.local/share/sounds/macshell (shipped ones, plus the rest synthesized by macshell-make-sounds.py)
# the update tool to ~/.local/share/macshell/bin/macshell-update (+ ~/.local/bin/macshell-update)
# the start script to ~/.local/share/macshell/bin/macshell-start (+ ~/.local/bin/macshell-start)
# 4. installs ~/.config/hypr/macshell.lua with the autostart and keybinds, then loads it from hyprland.lua
# (Hyprland 0.55+), or adds an exec-once line to hyprland.conf. It never writes to a config Hyprland is not using.
# 5. optionally sets up automatic updates (a daily systemd user timer)
#
# Updates
# Run ./install.sh and pick from the menu: 1) install shell, 2) check for updates (asks whether to install one),
# 3) uninstall shell, 4) bind help (opens the Hyprland keybind section of the README).
# An update installs the dependencies the new version needs, updates MacShell and MacLock together and keeps your
# settings. Use --local to install exactly what is in a clone, or --check to only look.
# (macshell-update still exists for the daily timer and for scripts; "macshell-update rollback" restores both.)
#
# Login screen
# ./install.sh --login-screen (or switch on "Login screen" in the graphical installer) replaces your display manager with
# greetd and shows MacLock's lock screen as the login screen. Nothing changes until you reboot; --remove-login-screen undoes it.
# See MacGreeter/README.md.
#
# Your settings (~/.config/macbar, macdock, macshell, macwidgets, ...) are never touched.
# Before replacing an existing install, the old one is saved to ~/.local/share/macshell/backups/ (last 3 kept).
#
# Options
# -y, --yes do not ask questions (answer yes)
# --no-deps skip the dependency check
# --deps-only only check / install dependencies, then stop
# --no-services do not enable system services (bluetooth, NetworkManager, power profiles, PipeWire)
# --doctor check the whole setup (environment, QML modules, services, wallpaper, shaders, Hyprland, the last
# start log) and explain problems
# --deps same as --deps-only
# --deps-plan print what the dependency step would install, as one line of JSON (used by the shell's Installer)
# --no-start do not offer to start MacShell at the end
# --no-verify start MacShell without waiting to see whether it stays up
# --low-power settings for older computers (no live window capture, no magnification, plain blur)
# --no-autostart do not touch the Hyprland config
# --no-rules do not add the Liquid Glass layer rules to the Hyprland config
# --channel CH release (default: latest release, else the main branch) or main (always the newest commit)
# --ref REF install a specific tag / commit instead of the latest
# --from-dir DIR install from a local folder instead of downloading
# --update quiet update mode (used by macshell-update)
# --uninstall remove MacShell (settings are kept)
# --no-lock do not install MacLock
# --login-screen use MacLock as the login screen (greetd + MacGreeter; Arch only, asks for sudo, needs MacShell installed)
# --remove-login-screen put the previous display manager back and remove the login screen
# --login-status print the login screen's state as one line of JSON (used by the graphical installer)
# --login-sync refresh the wallpaper / picture / settings the login screen shows (no sudo)
# --gui use the graphical installer (MacInstaller): installs what it needs to run, then opens it
# --no-gui never offer the graphical installer
# --check only check whether a newer version exists (exit 0 = up to date, 10 = update available)
# --local install the local copy as it is, do not look for a newer version on GitHub
# --auto-update install a daily systemd user timer that updates MacShell + MacLock by itself
# --no-auto-update remove that timer
# -h, --help
#
# Environment variables for the shell itself (icon theme, Qt platform, software rendering, ...) go in
# ~/.config/macshell/env (the installer creates it with comments; macshell-start reads it)
#
# Environment: MACSHELL_FROM_DIR (install from this folder instead of downloading: the graphical installer sets it),
# MACSHELL_REPO (default 0-ss/MacShell), MACSHELL_BRANCH (default main), MACSHELL_CHANNEL, MACSHELL_DEST,
# MACLOCK_DEST, GITHUB_TOKEN
set -euo pipefail
REPO="${MACSHELL_REPO:-0-ss/MacShell}"
BRANCH="${MACSHELL_BRANCH:-main}"
NAME="MacShell"
CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
DEST="${MACSHELL_DEST:-$CONFIG_HOME/quickshell/$NAME}"
LOCK_NAME="MacLock"
LOCK_DEST="${MACLOCK_DEST:-$CONFIG_HOME/quickshell/$LOCK_NAME}"
STATE_DIR="$DATA_HOME/macshell"
GUI_NAME="MacInstaller"
GUI_DEST="$STATE_DIR/$GUI_NAME"
GREETER_NAME="MacGreeter" # the login screen (a copy of MacLock's look + greetd); the source lives here, the system copy below
GREETER_DEST="$STATE_DIR/$GREETER_NAME"
GREETER_SYS="/usr/local/share/macshell-greeter"
GREETER_VAR="/var/lib/macshell-greeter"
LOGIN_ACTION="" # setup | remove | status | sync
BIN_DIR="$STATE_DIR/bin"
BACKUP_DIR="$STATE_DIR/backups"
HYPR_MAC_DIR="$CONFIG_HOME/hypr-macshell"
SCRIPTS_DIR="$HYPR_MAC_DIR/scripts"
APPS_DIR="$DATA_HOME/applications"
ICONS_DIR="$DATA_HOME/icons/hicolor/scalable/apps"
FONTCONF_DIR="$CONFIG_HOME/fontconfig/conf.d"
SOUNDS_DIR="$DATA_HOME/sounds/macshell"
LINK_DIR="$HOME/.local/bin"
HYPR_DIR="$CONFIG_HOME/hypr"
MARK_BEGIN="-- >>> MacShell (added by install.sh) >>>"
MARK_END="-- <<< MacShell <<<"
MACLUA_BEGIN="-- >>> MacShell module (added by install.sh) >>>"
MACLUA_END="-- <<< MacShell module <<<"
CONF_BEGIN="# >>> MacShell (added by install.sh) >>>"
CONF_END="# <<< MacShell <<<"
ENV_DIR="$CONFIG_HOME/macshell"
DOCTOR=0
GUI="" # yes | no | "" (ask)
GUI_ASKED=0
GUI_SKIPPED_DEPS=0
DEPS_PLAN=0
NO_START=0
NO_VERIFY=0
LOW_POWER=0
MODE_FLAG=0 # a mode option was given (no menu)
ASSUME_YES=0
SKIP_DEPS=0
DEPS_ONLY=0
SKIP_SERVICES=0
SKIP_AUTOSTART=0
SKIP_RULES=0
SKIP_LOCK=0
CHECK_ONLY=0
LOCAL_ONLY=0
AUTO_UPDATE=""
BACKUP_TS=""
UPDATE_MODE=0
UNINSTALL=0
REF=""
FROM_DIR=""
CHANNEL="${MACSHELL_CHANNEL:-}"
RESOLVED_ID=""
RESOLVED_TYPE=""
RESOLVED_VER="" # the version number of RESOLVED_ID (e.g. 0.3.8), when known
# ───────────────────────── output helpers ─────────────────────────
if [ -t 1 ]; then B=$'\033[1m'; G=$'\033[32m'; Y=$'\033[33m'; R=$'\033[31m'; D=$'\033[2m'; N=$'\033[0m'; else B=""; G=""; Y=""; R=""; D=""; N=""; fi
say() { printf '%s\n' "$*"; }
step() { printf '%s==>%s %s%s%s\n' "$G" "$N" "$B" "$*" "$N"; }
ok() { printf ' %s✓%s %s\n' "$G" "$N" "$*"; }
warn() { printf ' %s!%s %s\n' "$Y" "$N" "$*" >&2; }
die() { printf '%serror:%s %s\n' "$R" "$N" "$*" >&2; exit 1; }
have() { command -v "$1" >/dev/null 2>&1; }
# sed -i that edits through a symlink (dotfile managers link hyprland.lua) instead of replacing it with a plain file
sedi() { sed -i --follow-symlinks "$@" 2>/dev/null || sed -i "$@"; }
# "does this text match": a here-string, not a pipe. With pipefail, `cmd | grep -q` reports failure whenever grep quits
# early and cmd is killed by SIGPIPE, which made the installer claim that installed fonts were missing.
text_has() { grep -Eqi -- "$2" <<<"$1"; }
same_version() { [ "${1#v}" = "${2#v}" ]; }
# version helpers (0.3.7, v1.2 ...)
is_ver() { [[ "${1:-}" =~ ^v?[0-9]+(\.[0-9]+)*$ ]]; }
ver_ge() { # ver_ge A B: is A the same as, or newer than, B?
local a="${1#v}" b="${2#v}"
[ "$(printf '%s\n%s\n' "$a" "$b" | sort -V | tail -n1)" = "$a" ]
}
# confirm "question" [default y|n]
confirm() {
local def="${2:-y}" ans="" hint="[Y/n]"
[ "$def" = n ] && hint="[y/N]"
[ "$ASSUME_YES" = 1 ] && return 0
if [ -r /dev/tty ] && [ -w /dev/tty ]; then
printf '%s %s ' "$1" "$hint" >/dev/tty
read -r ans </dev/tty || ans=""
else
ans=""
fi
case "${ans:-$def}" in [Yy]*) return 0 ;; *) return 1 ;; esac
}
usage() { sed -n '2,/^set -euo/p' "$0" | sed '$d' | sed 's/^# \{0,1\}//'; }
# ───────────────────────── arguments ─────────────────────────
while [ $# -gt 0 ]; do
case "$1" in
-y|--yes) ASSUME_YES=1 ;;
--no-deps) SKIP_DEPS=1 ;;
--deps-only|--deps) DEPS_ONLY=1; MODE_FLAG=1 ;;
--deps-plan) DEPS_PLAN=1; SKIP_DEPS=1; ASSUME_YES=1; MODE_FLAG=1 ;;
--no-start) NO_START=1 ;;
--no-verify) NO_VERIFY=1 ;;
--no-services) SKIP_SERVICES=1 ;;
--doctor) DOCTOR=1; MODE_FLAG=1 ;;
--low-power) LOW_POWER=1 ;;
--no-autostart) SKIP_AUTOSTART=1 ;;
--no-rules) SKIP_RULES=1 ;;
--no-lock) SKIP_LOCK=1 ;;
--login-screen) LOGIN_ACTION=setup; SKIP_DEPS=1; MODE_FLAG=1 ;;
--remove-login-screen) LOGIN_ACTION=remove; SKIP_DEPS=1; MODE_FLAG=1 ;;
--login-status) LOGIN_ACTION=status; SKIP_DEPS=1; ASSUME_YES=1; MODE_FLAG=1 ;;
--login-sync) LOGIN_ACTION=sync; SKIP_DEPS=1; ASSUME_YES=1; MODE_FLAG=1 ;;
--gui) GUI=yes; MODE_FLAG=1 ;;
--no-gui) GUI=no ;;
--check) CHECK_ONLY=1; SKIP_DEPS=1; MODE_FLAG=1 ;;
--local) LOCAL_ONLY=1; MODE_FLAG=1 ;;
--auto-update) AUTO_UPDATE=yes ;;
--no-auto-update) AUTO_UPDATE=no ;;
--update) UPDATE_MODE=1; SKIP_AUTOSTART=1; SKIP_SERVICES=1; ASSUME_YES=1; MODE_FLAG=1 ;;
--uninstall) UNINSTALL=1; MODE_FLAG=1 ;;
--channel) CHANNEL="${2:-}"; shift ;;
--ref) REF="${2:-}"; MODE_FLAG=1; shift ;;
--from-dir) FROM_DIR="${2:-}"; MODE_FLAG=1; shift ;;
--resolved-id) RESOLVED_ID="${2:-}"; shift ;;
--resolved-type) RESOLVED_TYPE="${2:-}"; shift ;;
-h|--help) usage; exit 0 ;;
*) die "unknown option: $1 (try --help)" ;;
esac
shift
done
# set by the macshell-installer launcher: install from the clone it was started from (if that folder still exists)
if [ -z "$FROM_DIR" ] && [ -n "${MACSHELL_FROM_DIR:-}" ] && [ -d "$MACSHELL_FROM_DIR" ]; then FROM_DIR="$MACSHELL_FROM_DIR"; fi
state_get() { [ -f "$STATE_DIR/state.env" ] && sed -n "s/^$1=//p" "$STATE_DIR/state.env" | head -n1 || true; }
[ -n "$CHANNEL" ] || CHANNEL="$(state_get channel_pref)"
[ -n "$CHANNEL" ] || CHANNEL="release"
case "$CHANNEL" in release|main) ;; *) die "--channel must be 'release' or 'main'" ;; esac
[ "$(id -u)" -eq 0 ] && warn "running as root: MacShell is installed per user, run this as your normal user instead."
# ───────────────────────── automatic updates (systemd user timer) ─────────────────────────
UNIT_DIR="$CONFIG_HOME/systemd/user"
remove_auto_update() {
have systemctl && systemctl --user disable --now macshell-update.timer >/dev/null 2>&1 || true
rm -f "$UNIT_DIR/macshell-update.timer" "$UNIT_DIR/macshell-update.service"
have systemctl && systemctl --user daemon-reload >/dev/null 2>&1 || true
[ "${1:-}" = quiet ] || ok "automatic updates removed"
}
setup_auto_update() {
if ! have systemctl || ! systemctl --user show-environment >/dev/null 2>&1; then
warn "systemd user session not available: automatic updates were not set up (run 'macshell-update update' by hand)"
return 0
fi
mkdir -p "$UNIT_DIR"
local upd="$BIN_DIR/macshell-update update --yes --notify"
[ -x "$BIN_DIR/macshell-update" ] || upd="$BIN_DIR/macshell-install --update"
cat > "$UNIT_DIR/macshell-update.service" <<UNIT
[Unit]
Description=Update MacShell and MacLock from GitHub
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=$upd
UNIT
cat > "$UNIT_DIR/macshell-update.timer" <<UNIT
[Unit]
Description=Check for MacShell updates daily
[Timer]
OnCalendar=daily
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
UNIT
systemctl --user daemon-reload
if systemctl --user enable --now macshell-update.timer >/dev/null 2>&1; then
ok "automatic updates on (daily): systemctl --user list-timers macshell-update.timer"
else
warn "could not enable macshell-update.timer"
fi
}
# ───────────────────────── uninstall ─────────────────────────
remove_hypr_blocks() {
local f
for f in "$HYPR_DIR/hyprland.lua"; do
[ -f "$f" ] && grep -qF -- "$MARK_BEGIN" "$f" && { sedi "\|$MARK_BEGIN|,\|$MARK_END|d" "$f"; ok "removed the MacShell block from $f"; }
done
f="$HYPR_DIR/macshell.lua"
if [ -f "$f" ] && grep -qF -- "$MACLUA_BEGIN" "$f"; then
if [ -f "$f.macshell-backup" ]; then mv -f "$f.macshell-backup" "$f"; else rm -f "$f"; fi
ok "removed the generated MacShell module from $f"
fi
f="$HYPR_DIR/hyprland.conf"
[ -f "$f" ] && grep -qF -- "$CONF_BEGIN" "$f" && { sedi "\|$CONF_BEGIN|,\|$CONF_END|d" "$f"; ok "removed the MacShell block from $f"; }
return 0
}
do_uninstall() {
step "Uninstalling MacShell"
if [ -d "$DEST" ]; then
ts=$(date +%Y%m%d-%H%M%S); mkdir -p "$BACKUP_DIR/$ts"
mv "$DEST" "$BACKUP_DIR/$ts/$NAME"; ok "moved $DEST to $BACKUP_DIR/$ts/"
else
warn "$DEST does not exist"
fi
if [ -d "$LOCK_DEST" ]; then
ts=${ts:-$(date +%Y%m%d-%H%M%S)}; mkdir -p "$BACKUP_DIR/$ts"
mv "$LOCK_DEST" "$BACKUP_DIR/$ts/$LOCK_NAME"; ok "moved $LOCK_DEST to $BACKUP_DIR/$ts/"
fi
remove_auto_update quiet
remove_hypr_blocks
if [ -f "$GREETER_SYS/shell.qml" ]; then
warn "the login screen is still set up: run macshell-install --remove-login-screen first if you want your old login screen back"
fi
rm -rf "$GREETER_DEST"; rm -f "$LINK_DIR/macshell-greeter-sync" "$BIN_DIR/macshell-greeter-sync"
rm -rf "$GUI_DEST"; rm -f "$LINK_DIR/macshell-installer" "$BIN_DIR/macshell-installer" "$APPS_DIR/macshell-installer.desktop"
rm -f "$LINK_DIR/macshell-update" "$LINK_DIR/macshell-start" "$BIN_DIR/macshell-update" "$BIN_DIR/macshell-start" "$STATE_DIR/state.env"
ok "removed the update and start tools"
say "Your settings were kept (~/.config/macbar, macdock, macshell, macwidgets). The helper tree stays in $HYPR_MAC_DIR (remove it by hand if you like)."
say "If you added them yourself, remove the MacShell autostart and the MacLock lock keybind from your Hyprland config."
exit 0
}
[ "$UNINSTALL" = 1 ] && do_uninstall
# ───────────────────────── dependencies ─────────────────────────
# command:arch-package:what-for (a check by command name; package names are Arch names, translated per distro below)
REQUIRED=(
"qs:quickshell:the shell runtime (needs the Hyprland, Screencopy, PipeWire, UPower, Mpris and Notifications modules)"
"hyprctl:hyprland:the compositor (0.55+ with a Lua config)"
"curl:curl:weather, update checks, downloads"
"tar:tar:unpacking downloads"
"xdg-open:xdg-utils:opening files and links"
)
OPTIONAL=(
"pw-play:pipewire:UI sound effects"
"wpctl:wireplumber:audio device routing"
"pactl:pipewire-pulse:volume and audio devices (PulseAudio compatibility)"
"qsb:qt6-shadertools:recompiling the Liquid Glass shader (precompiled .qsb files are shipped)"
"wl-copy:wl-clipboard:clipboard"
"cliphist:cliphist:clipboard history"
"grim:grim:screenshots"
"slurp:slurp:screenshot region picker"
"wf-recorder:wf-recorder:screen recording"
"hyprpicker:hyprpicker:color picker"
"nmcli:networkmanager:Wi-Fi in Control Center"
"bluetoothctl:bluez-utils:Bluetooth (also needs the bluetooth service, enabled below)"
"rfkill:util-linux:Bluetooth / Airplane Mode (unblocking the adapter)"
"brightnessctl:brightnessctl:display brightness"
"playerctl:playerctl:media keys (play / pause / next / previous)"
"powerprofilesctl:power-profiles-daemon:power profiles / Game Mode"
"inotifywait:inotify-tools:live wallpaper watching, Trash watching"
"hyprsunset:hyprsunset:Night Shift"
"notify-send:libnotify:notifications from scripts, update notices"
"awww:awww:setting the wallpaper"
"mpvpaper:mpvpaper:animated (video) wallpapers"
"ffmpeg:ffmpeg:video wallpaper thumbnails and previews"
"zenity:zenity:file pickers (image widgets, Settings folders)"
"magick:imagemagick:profile picture conversion"
"fastfetch:fastfetch:About This Linux"
"rsync:rsync:faster, safer file sync in the installer"
"jq:jq:wallpaper helpers (reading the dock / shell settings)"
"python3:python:UI sound generation and AirDrop"
"kitty:kitty:the default terminal"
"hypridle:hypridle:lock on idle (optional)"
"wtype:wtype:menu bar keyboard shortcuts in browsers and apps"
)
# libraries / fonts / packages without a command to test: arch-package:what-for (a|b = first one the repositories have)
LIBS=(
"qt6-declarative:Qt Quick (QML)"
"qt6-wayland:Qt Wayland support"
"qt6-svg:SVG app icons"
"qt6-shadertools:shader tools"
"qt6-multimedia-ffmpeg|qt6-multimedia:QtMultimedia (video wallpapers; MacShell and MacLock fail to load without it)"
"upower:battery and power status (Quickshell UPower)"
"inter-font|ttf-inter:the Inter font"
"noto-fonts:fallback fonts"
"noto-fonts-emoji:emoji font"
"papirus-icon-theme:an icon theme for app icons"
"mesa:OpenGL drivers (Qt Quick draws with OpenGL; needed on every GPU)"
"xdg-desktop-portal-hyprland:screen sharing and screenshots through portals"
"polkit:privilege prompts"
)
LIBS_LOCK=(
"hyprlock:the PAM stack MacLock checks passwords with (/etc/pam.d/hyprlock)"
)
PM="" # pacman | dnf | apt
SUDO=""
CAN_INSTALL=1
detect_pm() {
if have pacman; then PM=pacman
elif have dnf; then PM=dnf
elif have apt-get; then PM=apt
fi
SUDO=""
if [ "$(id -u)" -ne 0 ]; then
if have sudo; then SUDO="sudo"; elif have doas; then SUDO="doas"; fi
# unattended updates (systemd timer) cannot type a password: only install when sudo works without one
if [ "$UPDATE_MODE" = 1 ]; then
if [ "$SUDO" = sudo ] && sudo -n true >/dev/null 2>&1; then SUDO="sudo -n"; else CAN_INSTALL=0; fi
fi
fi
}
# arch package name(s) -> package name(s) for this distro, alternatives separated by "|" ("" = unknown, skipped)
pkg_for() {
local p="$1"
case "$PM" in
pacman) printf '%s' "$p" ;;
dnf) case "$p" in
pipewire) echo pipewire-utils ;; pipewire-pulse) echo pipewire-pulseaudio ;;
qt6-shadertools) echo qt6-qtshadertools ;; qt6-declarative) echo qt6-qtdeclarative ;;
"qt6-multimedia-ffmpeg|qt6-multimedia") echo qt6-qtmultimedia ;;
qt6-wayland) echo qt6-qtwayland ;; qt6-svg) echo qt6-qtsvg ;; networkmanager) echo NetworkManager ;;
bluez-utils) echo bluez ;; "inter-font|ttf-inter") echo rsms-inter-fonts ;;
noto-fonts) echo google-noto-sans-fonts ;; noto-fonts-emoji) echo "google-noto-color-emoji-fonts|google-noto-emoji-fonts" ;;
imagemagick) echo ImageMagick ;; python) echo python3 ;; awww|mpvpaper|cliphist) echo "$p" ;; *) printf '%s' "${p%%|*}" ;;
esac ;;
apt) case "$p" in
pipewire) echo pipewire-bin ;; pipewire-pulse) echo pipewire-pulse ;; qt6-shadertools) echo qt6-shader-baker ;;
"qt6-multimedia-ffmpeg|qt6-multimedia") echo qml6-module-qtmultimedia ;;
networkmanager) echo network-manager ;; bluez-utils) echo bluez ;; libnotify) echo libnotify-bin ;;
"inter-font|ttf-inter") echo fonts-inter ;; noto-fonts) echo fonts-noto-core ;;
noto-fonts-emoji) echo fonts-noto-color-emoji ;; python) echo python3 ;; qt6-declarative|qt6-wayland|qt6-svg) echo "" ;;
*) printf '%s' "${p%%|*}" ;;
esac ;;
esac
}
pkg_installed() { # distro package name
case "$PM" in
pacman) pacman -Qq "$1" >/dev/null 2>&1 ;;
dnf) rpm -q "$1" >/dev/null 2>&1 ;;
apt) dpkg -s "$1" >/dev/null 2>&1 ;;
*) return 1 ;;
esac
}
pkg_available() { # in the distro's repositories?
case "$PM" in
pacman) pacman -Si "$1" >/dev/null 2>&1 ;;
dnf) dnf -q info "$1" >/dev/null 2>&1 ;;
apt) apt-cache show "$1" >/dev/null 2>&1 ;;
*) return 1 ;;
esac
}
# first alternative of "a|b" that is installed / available (empty if none)
first_installed() { local a; IFS='|' read -ra alts <<<"$1"; for a in "${alts[@]}"; do pkg_installed "$a" && { printf '%s' "$a"; return 0; }; done; return 1; }
first_available() { local a; IFS='|' read -ra alts <<<"$1"; for a in "${alts[@]}"; do pkg_available "$a" && { printf '%s' "$a"; return 0; }; done; return 1; }
APT_UPDATED=0
install_packages() { # install_packages <distro package names...>
[ "$#" -gt 0 ] || return 0
if [ "$CAN_INSTALL" != 1 ]; then
warn "cannot ask for a password in an unattended update; install these yourself: $*"; return 1
fi
if [ -z "$SUDO" ] && [ "$(id -u)" -ne 0 ]; then
warn "no sudo/doas found: install these yourself: $*"; return 1
fi
case "$PM" in
pacman) $SUDO pacman -S --needed --noconfirm "$@" ;;
dnf) $SUDO dnf install -y "$@" ;;
apt)
# package lists on a fresh system are often empty or stale: refresh them once
if [ "$APT_UPDATED" != 1 ]; then $SUDO apt-get update || true; APT_UPDATED=1; fi
$SUDO apt-get install -y "$@" ;;
esac
}
# Arch: which packages you already have would installing "$@" upgrade as well? (a partial upgrade, which Arch does not
# support: it is the usual reason a package installs fine and the shell then fails with a library error)
pacman_upgrades() {
[ "$PM" = pacman ] || return 0
local out n
out=$(pacman -S --needed --print --print-format '%n' "$@" 2>/dev/null) || return 0
while IFS= read -r n; do
if [ -n "$n" ] && pacman -Qq "$n" >/dev/null 2>&1; then printf '%s\n' "$n"; fi
done <<<"$out"
return 0
}
offer_full_upgrade() { # offer_full_upgrade <packages about to be installed>
[ "$PM" = pacman ] || return 0
local upg; upg=$(pacman_upgrades "$@")
[ -n "$upg" ] || return 0
warn "installing these would also upgrade packages you already have ($(printf '%s' "$upg" | tr '\n' ' ')): Arch does not support partial upgrades"
if [ "$ASSUME_YES" != 1 ] && [ "$UPDATE_MODE" != 1 ] && confirm "Run a full system upgrade first (pacman -Syu)?" y; then
$SUDO pacman -Syu || warn "the system upgrade did not finish: continuing anyway"
else
say " Continuing without a full upgrade. If a package then fails to install or the shell fails to start, run: sudo pacman -Syu"
fi
return 0
}
# On Arch: build yay-bin from the AUR so packages that are not in the official repositories (awww, mpvpaper, sometimes
# quickshell) can be installed too.
AUR_HELPER=""
find_aur_helper() { AUR_HELPER=""; if have yay; then AUR_HELPER=yay; elif have paru; then AUR_HELPER=paru; fi; }
bootstrap_aur_helper() {
[ "$PM" = pacman ] && [ "$(id -u)" -ne 0 ] && [ "$CAN_INSTALL" = 1 ] || return 1
[ "$UPDATE_MODE" = 1 ] && return 1 # never build an AUR helper unattended
confirm "No AUR helper found. Install yay (built from the AUR) to get packages that are not in the official repositories?" y || return 1
install_packages git base-devel || return 1
local tmp; tmp=$(mktemp -d)
if git clone --depth 1 https://aur.archlinux.org/yay-bin.git "$tmp/yay-bin" >/dev/null 2>&1 \
&& (cd "$tmp/yay-bin" && makepkg -si --noconfirm); then
rm -rf "$tmp"; ok "yay installed"; find_aur_helper; return 0
fi
rm -rf "$tmp"; warn "could not build yay"; return 1
}
# quickshell (and a few others) are not in every repository: try an AUR helper / the Fedora COPR
MANUAL_LIST=()
install_extra_sources() {
local missing=("$@") p
[ "${#missing[@]}" -gt 0 ] || return 0
case "$PM" in
pacman)
find_aur_helper
[ -n "$AUR_HELPER" ] || bootstrap_aur_helper || true
if [ -n "$AUR_HELPER" ] && [ "$CAN_INSTALL" = 1 ]; then
for p in "${missing[@]}"; do
say " $p is not in the official repositories: trying the AUR ($AUR_HELPER)"
"$AUR_HELPER" -S --needed --noconfirm "$p" || { warn "could not install $p from the AUR"; MANUAL_LIST+=("$p"); }
done
else
warn "not in the official repositories: ${missing[*]} (install an AUR helper such as yay, then: yay -S ${missing[*]})"
MANUAL_LIST+=("${missing[@]}")
fi ;;
dnf)
if [ "$CAN_INSTALL" = 1 ] && printf '%s\n' "${missing[@]}" | grep -qx quickshell; then
say " quickshell: enabling the errornospam/quickshell COPR"
$SUDO dnf copr enable -y errornospam/quickshell && $SUDO dnf install -y quickshell || { warn "could not install quickshell"; MANUAL_LIST+=(quickshell); }
missing=("${missing[@]/quickshell}")
fi
for p in "${missing[@]}"; do [ -n "$p" ] && MANUAL_LIST+=("$p"); done
printf '%s\n' "${missing[@]}" | grep -qx hyprland && warn "hyprland is not in your repositories: see https://wiki.hyprland.org"
;;
apt)
warn "not in the Debian/Ubuntu repositories: ${missing[*]}. Build them from source: https://quickshell.org and https://wiki.hyprland.org"
MANUAL_LIST+=("${missing[@]}") ;;
esac
}
# Video wallpapers need mpvpaper (+ ffmpeg for thumbnails). check_deps already tries to install it; this makes sure it
# is not silently skipped, and says exactly what to run when the package manager cannot provide it.
ensure_mpvpaper() {
have mpvpaper && return 0
[ -n "$PM" ] || { warn "mpvpaper is missing: video wallpapers need it"; return 0; }
local failed=0 m
for m in "${MANUAL_LIST[@]:-}"; do [ "$m" = mpvpaper ] && failed=1; done
if [ "$failed" = 0 ] && [ "$CAN_INSTALL" = 1 ] && confirm "Install mpvpaper now (needed for video wallpapers)?" y; then
if pick=$(first_available mpvpaper); then install_packages "$pick" || true
else install_extra_sources mpvpaper; fi
fi
if have mpvpaper; then ok "mpvpaper installed"; return 0; fi
case "$PM" in
pacman) warn "mpvpaper is not installed: video wallpapers will not work. Run: yay -S mpvpaper (or paru -S mpvpaper)" ;;
dnf) warn "mpvpaper is not installed: video wallpapers will not work. It is not in the Fedora repositories: build it from https://github.com/GhostNaN/mpvpaper" ;;
*) warn "mpvpaper is not installed: video wallpapers will not work. Install it with your package manager or build it from https://github.com/GhostNaN/mpvpaper" ;;
esac
}
# A command can be installed without being in PATH (qsb lives in /usr/lib/qt6/bin): ask find_qsb, not PATH
have_cmd() { if [ "$1" = qsb ]; then find_qsb >/dev/null 2>&1; else have "$1"; fi; }
# Fonts: is the Inter family known to fontconfig? (pipe-free: see text_has)
has_inter_font() {
have fc-list || return 1
local out; out=$(fc-list : family 2>/dev/null) || true
grep -Eqi -- '(^|,)[[:space:]]*Inter([[:space:]]+(Variable|Display|Tight))*[[:space:]]*(,|$)' <<<"$out"
}
# QML modules the shell imports. A missing one makes Quickshell refuse to load the whole config, which shows up as
# "MacShell is crashing on launch". module-folder:arch-package(s)
QML_MODULES=(
"QtMultimedia:qt6-multimedia-ffmpeg|qt6-multimedia"
"QtQuick/Effects:qt6-declarative"
"QtQuick/Controls:qt6-declarative"
"QtQuick/Shapes:qt6-declarative"
"Quickshell/Io:quickshell"
"Quickshell/Wayland:quickshell"
"Quickshell/Hyprland:quickshell"
"Quickshell/Services/UPower:quickshell"
"Quickshell/Services/Mpris:quickshell"
"Quickshell/Services/Pipewire:quickshell"
"Quickshell/Services/Notifications:quickshell"
"Quickshell/Services/SystemTray:quickshell"
)
QML_DIRS=()
qml_dirs() {
[ "${#QML_DIRS[@]}" -eq 0 ] || return 0
local q out d
for q in qtpaths6 qtpaths-qt6 qmake6 qmake-qt6; do
have "$q" || continue
case "$q" in
qtpaths*) out=$("$q" --query QT_INSTALL_QML 2>/dev/null || true) ;;
*) out=$("$q" -query QT_INSTALL_QML 2>/dev/null || true) ;;
esac
if [ -n "$out" ] && [ -d "$out" ]; then QML_DIRS+=("$out"); fi
done
for d in /usr/lib/qt6/qml /usr/lib64/qt6/qml /usr/lib/qt/qml /usr/lib/*/qt6/qml /usr/local/lib/qt6/qml /usr/local/lib64/qt6/qml; do
if [ -d "$d" ]; then QML_DIRS+=("$d"); fi
done
local IFS=:
for d in ${QML_IMPORT_PATH:-} ${QML2_IMPORT_PATH:-}; do
if [ -n "$d" ] && [ -d "$d" ]; then QML_DIRS+=("$d"); fi
done
return 0
}
qml_module_present() { # qml_module_present QtQuick/Effects
local d; qml_dirs
for d in "${QML_DIRS[@]}"; do [ -d "$d/$1" ] && return 0; done
return 1
}
missing_qml_modules() { # prints "module:package" for every module that is not there
local entry mod
for entry in "${QML_MODULES[@]}"; do
mod="${entry%%:*}"
qml_module_present "$mod" || printf '%s\n' "$entry"
done
return 0
}
describe_missing_qml() { # describe_missing_qml <module:package>
local mod="${1%%:*}" pkg="${1#*:}" dp
if [ "$pkg" = quickshell ]; then
printf '%s (your Quickshell build lacks it: install the complete quickshell package, not a trimmed build)' "$mod"
else
dp=$(pkg_for "$pkg" 2>/dev/null || true); dp="${dp:-$pkg}"
printf '%s (install %s)' "$mod" "${dp%%|*}"
fi
}
# What the dependency step would do, as one JSON line (the shell's Installer app reads it). Nothing is installed.
json_arr() { local out="" a; for a in "$@"; do [ -n "$a" ] || continue; out="$out${out:+,}\"$a\""; done; printf '[%s]' "$out"; }
run_deps_plan() {
detect_pm
if [ "$PM" != pacman ]; then
printf '{"pacman":false,"have":[],"repo":[],"aur":[],"skipped":[],"upgrades":[]}\n'; return 0
fi
local have_l=() want=() repo_l=() aur_l=() upg_l=() entry cmd pkg why p pick seen=" " n
local libs=("${LIBS[@]}")
[ "$SKIP_LOCK" = 1 ] || libs+=("${LIBS_LOCK[@]}")
for entry in "${REQUIRED[@]}" "${OPTIONAL[@]}"; do
IFS=: read -r cmd pkg why <<<"$entry"
if have_cmd "$cmd"; then have_l+=("${pkg%%|*}"); else want+=("$pkg"); fi
done
for entry in "${libs[@]}"; do
IFS=: read -r pkg why <<<"$entry"
if first_installed "$pkg" >/dev/null; then have_l+=("${pkg%%|*}"); else want+=("$pkg"); fi
done
for p in "${want[@]:-}"; do
[ -n "$p" ] || continue
case "$seen" in *" $p "*) continue ;; esac; seen="$seen$p "
if pick=$(first_available "$p"); then repo_l+=("$pick"); else aur_l+=("${p%%|*}"); fi
done
if [ "${#repo_l[@]}" -gt 0 ]; then
while IFS= read -r n; do [ -n "$n" ] && upg_l+=("$n"); done < <(pacman_upgrades "${repo_l[@]}")
fi
printf '{"pacman":true,"have":%s,"repo":%s,"aur":%s,"skipped":[],"upgrades":%s}\n' \
"$(json_arr "${have_l[@]:-}")" "$(json_arr "${repo_l[@]:-}")" "$(json_arr "${aur_l[@]:-}")" "$(json_arr "${upg_l[@]:-}")"
}
check_deps() {
step "Checking dependencies"
detect_pm
[ -n "$PM" ] || warn "no supported package manager (pacman, dnf, apt) found: dependencies can only be listed, not installed"
local to_install=() entry cmd pkg why p dp
local libs=("${LIBS[@]}")
[ "$SKIP_LOCK" = 1 ] || libs+=("${LIBS_LOCK[@]}")
for entry in "${REQUIRED[@]}"; do
IFS=: read -r cmd pkg why <<<"$entry"
if have_cmd "$cmd"; then ok "$cmd"; else warn "missing: $cmd ($why)"; to_install+=("$pkg"); fi
done
for entry in "${OPTIONAL[@]}"; do
IFS=: read -r cmd pkg why <<<"$entry"
if have_cmd "$cmd"; then ok "$cmd"; else say " ${D}- not found: $cmd ($why)${N}"; to_install+=("$pkg"); fi
done
for entry in "${libs[@]}"; do
IFS=: read -r pkg why <<<"$entry"
dp=$(pkg_for "$pkg")
[ -n "$dp" ] || continue
if [ -n "$PM" ] && first_installed "$dp" >/dev/null; then ok "${pkg%%|*}"; else say " ${D}- not found: ${pkg%%|*} ($why)${N}"; to_install+=("$pkg"); fi
done
# translate to this distro's names, drop duplicates / unknown ones, split into "repo" and "needs another source"
local repo=() extra=() seen=" " pick
for p in "${to_install[@]}"; do
dp=$(pkg_for "$p"); [ -n "$dp" ] || continue
case "$seen" in *" $dp "*) continue ;; esac; seen="$seen$dp "
[ -n "$PM" ] && first_installed "$dp" >/dev/null && continue
if [ -n "$PM" ] && pick=$(first_available "$dp"); then repo+=("$pick"); else extra+=("${dp%%|*}"); fi
done
if [ "${#repo[@]}" -eq 0 ] && [ "${#extra[@]}" -eq 0 ]; then
ok "all dependencies are installed"
elif [ -z "$PM" ]; then
say " Install the missing tools by hand (see the list above)."
else
say ""
say " Missing packages (${PM}): ${repo[*]:-none}${extra:+ | other sources: ${extra[*]}}"
if [ "$CAN_INSTALL" != 1 ]; then
warn "a newer MacShell may need: ${repo[*]:-} ${extra[*]:-}. Run the installer in a terminal to install them: bash install.sh --deps-only"
elif confirm "Install them now?" y; then
if [ "${#repo[@]}" -gt 0 ]; then
offer_full_upgrade "${repo[@]}"
install_packages "${repo[@]}" || {
warn "the package manager failed on the whole list, retrying one by one"
for p in "${repo[@]}"; do install_packages "$p" >/dev/null 2>&1 || { warn "could not install $p"; MANUAL_LIST+=("$p"); }; done
}
fi
if [ "${#extra[@]}" -gt 0 ]; then install_extra_sources "${extra[@]}"; fi
# a font that was just installed is not known to fontconfig until the cache is rebuilt
have fc-cache && fc-cache -f >/dev/null 2>&1 || true
else
say " Skipped. Install them later with your package manager, then run the installer again."
fi
fi
if ! has_inter_font; then
warn "the Inter font was not found (the shell falls back to another font)"
fi
if [ "${#MANUAL_LIST[@]}" -gt 0 ]; then
warn "still missing, install by hand: ${MANUAL_LIST[*]}"
fi
check_hyprland_version
ensure_mpvpaper
# the QML modules the shell imports: one missing module stops the whole shell from loading
local miss m shown=0
miss=$(missing_qml_modules)
if [ -n "$miss" ]; then
while IFS= read -r m; do
[ -n "$m" ] || continue
warn "QML module not found: $(describe_missing_qml "$m")"; shown=1
done <<<"$miss"
[ "$shown" = 1 ] && say " ${D}(MacShell cannot load without these. If it starts fine anyway, your Qt keeps its modules somewhere unusual: ignore this.)${N}"
else
ok "QML modules (QtMultimedia, Quickshell services, ...) found"
fi
# whatever is still missing among the required tools
for entry in "${REQUIRED[@]}"; do
IFS=: read -r cmd pkg why <<<"$entry"
if ! have "$cmd"; then
[ "$UPDATE_MODE" = 1 ] && continue
confirm "Required tool '$cmd' is still missing. Continue anyway?" n || die "install '$cmd' and run the installer again"
break
fi
done
return 0
}
# MacShell needs Hyprland 0.55+ (Lua config). Only a warning: the version can be unreadable outside a session.
check_hyprland_version() {
local v="" maj min
if have hyprctl; then v=$(hyprctl version 2>/dev/null | grep -oE 'v?[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1 || true); fi
[ -n "$v" ] || { have Hyprland && v=$(Hyprland --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1 || true); }
[ -n "$v" ] || return 0
v="${v#v}"; maj="${v%%.*}"; min="${v#*.}"; min="${min%%.*}"
if [ "$maj" -eq 0 ] 2>/dev/null && [ "$min" -lt 55 ] 2>/dev/null; then
warn "Hyprland $v found: MacShell needs 0.55 or newer (Lua config). Window actions, Alt+Tab focus and the Settings window need it."
else
ok "Hyprland $v"
fi
}
# Services a fresh Arch install does not start by itself: bluetoothd (Bluetooth), NetworkManager (Wi-Fi),
# power-profiles-daemon (power profiles / Game Mode) and the PipeWire user services (volume, sound).
unit_exists() { systemctl cat "$1" >/dev/null 2>&1; }
unit_on() { systemctl is-enabled --quiet "$1" 2>/dev/null || systemctl is-active --quiet "$1" 2>/dev/null; }
enable_services() {
[ "$SKIP_SERVICES" = 1 ] && return 0
have systemctl || return 0
systemctl show-environment >/dev/null 2>&1 || return 0 # not running under systemd (container, chroot)
local s="" entry unit why todo=()
[ "$(id -u)" -ne 0 ] && s="${SUDO:-sudo}"
if have bluetoothctl && unit_exists bluetooth.service && ! systemctl is-active --quiet bluetooth.service 2>/dev/null; then
todo+=("bluetooth.service|Bluetooth does nothing without it")
fi
if have powerprofilesctl && unit_exists power-profiles-daemon.service && ! unit_on power-profiles-daemon.service \
&& ! unit_on tlp.service && ! unit_on auto-cpufreq.service; then
todo+=("power-profiles-daemon.service|power profiles and Game Mode need it")
fi
if have nmcli && unit_exists NetworkManager.service && ! unit_on NetworkManager.service \
&& ! unit_on systemd-networkd.service && ! unit_on iwd.service && ! unit_on connman.service && ! unit_on dhcpcd.service; then
todo+=("NetworkManager.service|Wi-Fi in Control Center needs it, and nothing else manages your network")
fi
if [ "${#todo[@]}" -gt 0 ]; then
step "System services"
for entry in "${todo[@]}"; do
IFS='|' read -r unit why <<<"$entry"
if confirm "Enable and start $unit ($why)?" y; then
if $s systemctl enable --now "$unit"; then ok "$unit enabled and started"; else warn "could not enable $unit: run sudo systemctl enable --now ${unit%.service}"; fi
fi
done
fi
# PipeWire (user services): normally socket-activated; start them when nothing does
if systemctl --user show-environment >/dev/null 2>&1; then
local pw=() u
for u in pipewire.service pipewire-pulse.service wireplumber.service; do
systemctl --user cat "$u" >/dev/null 2>&1 || continue
systemctl --user is-active --quiet "$u" 2>/dev/null && continue
systemctl --user is-enabled --quiet "$u" 2>/dev/null && continue
pw+=("$u")
done
if [ "${#pw[@]}" -gt 0 ] && confirm "Enable the audio services (${pw[*]}); volume and sound need them?" y; then
systemctl --user enable --now "${pw[@]}" >/dev/null 2>&1 && ok "audio services enabled" || warn "could not enable ${pw[*]}"
fi
fi
return 0
}
# ───────────────────────── environment, folders, shaders ─────────────────────────
write_env_template() {
mkdir -p "$ENV_DIR"
[ -f "$ENV_DIR/env" ] && return 0
cat > "$ENV_DIR/env" <<'ENVF'
# MacShell environment. macshell-start reads this file before it starts the shell.
# One "export NAME=value" per line; remove the # to use a line.
# Icon theme for the Dock and Spotlight. Left empty, the start script picks your GTK icon theme, else Papirus,
# WhiteSur, Tela, Adwaita or breeze, whichever is installed.
#export QS_ICON_THEME=Papirus-Dark
# Qt theming through qt6ct (only if you installed and configured it; it then also decides the icon theme)
#export QT_QPA_PLATFORMTHEME=qt6ct
# Older graphics (old Intel / AMD, some laptops): if the shell is slow or draws wrongly, try these one at a time
#export QSG_RHI_BACKEND=opengl # use OpenGL, not Vulkan
#export QSG_RENDER_LOOP=basic # simpler render loop
#export QT_QUICK_BACKEND=software # last resort: software drawing (no Liquid Glass)
ENVF
ok "environment file -> $ENV_DIR/env"
}
ensure_dirs() {
mkdir -p "$HOME/Pictures/Wallpapers" "$HOME/Pictures/Screenshots" 2>/dev/null || true
}
find_qsb() {
local q
for q in qsb qsb6 qsb-qt6 /usr/lib/qt6/bin/qsb /usr/lib64/qt6/bin/qsb /usr/lib/qt/bin/qsb; do
if have "$q"; then printf '%s' "$q"; return 0; fi
done
return 1
}
# compile every shader that has no .qsb next to it (they normally ship precompiled)
build_shaders() { # build_shaders <installed-dir>
local d="$1" q f n=0
q=$(find_qsb) || { return 0; }
for f in "$d"/*.frag; do
[ -f "$f" ] || continue
[ -f "$f.qsb" ] && continue
if "$q" --qt6 -o "$f.qsb" "$f" >/dev/null 2>&1; then n=$((n+1)); else warn "could not compile $(basename "$f")"; rm -f "$f.qsb"; fi
done
[ "$n" -gt 0 ] && ok "$n shader(s) compiled with qsb" || true
return 0
}
# settings for older computers: no live window capture or magnification, plain blur
json_merge() { # json_merge <file> <json-object>
local f="$1" obj="$2"
mkdir -p "$(dirname "$f")"
if [ ! -s "$f" ]; then printf '%s\n' "$obj" > "$f"; return 0; fi
if have python3; then
python3 - "$f" "$obj" <<'PY'
import json, sys
f, add = sys.argv[1], json.loads(sys.argv[2])
try: cur = json.load(open(f))
except Exception: cur = {}
cur.update(add)
json.dump(cur, open(f, "w"), indent=2)
PY
return $?
fi
return 1
}
apply_low_power() {
step "Low-power settings (older computers)"
local ok1=0 ok2=0
json_merge "$CONFIG_HOME/macdock/settings.json" '{"windowCapture": false, "showThumbs": false, "magnificationEnabled": false, "dockStyle": "blur"}' && ok1=1
json_merge "$CONFIG_HOME/macbar/settings.json" '{"barStyle": "blur", "glassRealtime": false}' && ok2=1
if [ "$ok1" = 1 ] && [ "$ok2" = 1 ]; then
ok "live window capture, magnification and Liquid Glass are off"
say " Restart MacShell (log out and in) so it reads them. Turn things back on in Settings."
else
warn "could not edit the settings files (python3 missing?). In Settings turn off: Dock Behavior > Live window capture, Magnification, and set the Menu Bar style to Normal Blur."
fi
}
# ───────────────────────── is it running? what did it log? ─────────────────────────
shell_running() { pgrep -u "$(id -u)" -f "(^|/)(qs|quickshell)( .*)? (-c|--config) $NAME( |\$)" >/dev/null 2>&1; }
start_log() { printf '%s' "${XDG_STATE_HOME:-$HOME/.local/state}/macshell/$NAME.log"; }
multimedia_hint() {
[ -n "$PM" ] || detect_pm
case "$PM" in
pacman) printf 'sudo pacman -S qt6-multimedia-ffmpeg (then run bash install.sh again)' ;;
dnf) printf 'sudo dnf install qt6-qtmultimedia' ;;
apt) printf 'sudo apt install qml6-module-qtmultimedia' ;;
*) printf 'install the Qt 6 Multimedia QML module with your package manager' ;;
esac
}
# Turn the lines of a Quickshell log into advice: says what it recognised, always returns 0.
diagnose_log() { # diagnose_log <log text>
local t="$1" found=0 mod
while IFS= read -r mod; do
[ -n "$mod" ] || continue
found=1
case "$mod" in
QtMultimedia*) say " -> QtMultimedia is not installed: $(multimedia_hint)" ;;
*) say " -> the QML module \"$mod\" is not installed (a Qt or Quickshell package is missing)" ;;
esac
done < <(sed -n 's/.*module "\([^"]*\)" is not installed.*/\1/p' <<<"$t" | sort -u)
if text_has "$t" 'failed to create (the )?(rhi|opengl|egl|vulkan)|could not (initialize|create) (the )?(opengl|egl|rhi|graphics)|rhi.*(fail|error)|eglcreate|libegl|libgl\.so|no (opengl|gpu)|glx'; then
found=1
say " -> a graphics problem. Try these one at a time in ~/.config/macshell/env (remove the #):"
say " export QSG_RHI_BACKEND=opengl then export QSG_RENDER_LOOP=basic then export QT_QUICK_BACKEND=software"
say " and check that mesa and your GPU's driver are installed."
fi
if text_has "$t" 'org\.freedesktop\.notifications|notification.*(already|owned|in use)'; then
found=1; say " -> another notification daemon (dunst / mako / swaync) is running: stop it (bash install.sh offers to)"
fi
if text_has "$t" 'could not connect to display|failed to create wl_display|no wayland|wayland.*(no|not).*(compositor|display|socket)'; then
found=1; say " -> MacShell needs a running Hyprland (Wayland) session: start it from inside Hyprland"
fi
if text_has "$t" 'undefined symbol|cannot open shared object|error while loading shared libraries|version .* not found'; then
found=1; say " -> a library mismatch, usually after a partial system upgrade: run sudo pacman -Syu (and rebuild quickshell if it comes from the AUR)"
fi
if text_has "$t" 'segmentation fault|sigsegv|sigabrt|core dumped|has crashed|crash report'; then
found=1; say " -> Quickshell crashed. A crash report may be in ~/.cache/quickshell/crashes: include it and the log when you report this"
fi
if text_has "$t" 'syntaxerror|referenceerror|[a-z0-9_]+ is not a type|type [a-z0-9_]+ unavailable|unexpected token|parse error'; then
found=1; say " -> a QML file did not load: run bash install.sh again (it replaces the shell files), or macshell-update rollback"
fi
[ "$found" = 1 ] || say " -> no known cause in the log: run qs -c $NAME in a terminal to watch it start, and report what it prints"
return 0
}
# Start MacShell and watch it for a few seconds. Quickshell refusing to load the config (a missing module, a bad graphics
# driver) used to be invisible here: the installer printed "started" and the shell was already dead.
start_and_verify() {
have qs || return 1
local log before=0 i up=0 gone=0 t
log=$(start_log); mkdir -p "$(dirname "$log")" 2>/dev/null || true
if [ -f "$log" ]; then before=$(wc -c <"$log" | tr -d ' '); fi
if have setsid; then setsid nohup sh "$LINK_DIR/macshell-start" >/dev/null 2>&1 &
else nohup sh "$LINK_DIR/macshell-start" >/dev/null 2>&1 &
fi
if [ "$NO_VERIFY" = 1 ]; then ok "started"; return 0; fi
say " starting MacShell (waiting a few seconds to see that it stays up) ..."
for i in $(seq 1 50); do
sleep 0.5
if shell_running; then up=$((up + 1)); gone=0; else up=0; gone=$((gone + 1)); fi
[ "$up" -ge 12 ] && break # alive for 6 seconds in a row
# the start script gave up (it stops after repeated quick crashes) and nothing is running
if [ "$gone" -ge 6 ] && ! pgrep -u "$(id -u)" -f 'sh .*macshell-start' >/dev/null 2>&1; then break; fi
done
if [ "$up" -ge 12 ]; then ok "MacShell is running"; return 0; fi
warn "MacShell did not stay up. What it logged ($log):"
t=$(tail -c +$((before + 1)) "$log" 2>/dev/null | tail -n 40 || true)
if [ -n "$t" ]; then printf '%s\n' "$t" | tail -n 15 | sed 's/^/ /'; fi
diagnose_log "$t"
say " After fixing it: sh $LINK_DIR/macshell-start (or: bash install.sh --doctor)"
return 1
}
# Notification daemons own the one notification service on the bus; a second bar overlaps the menu bar.
stop_conflicts() {
local d unit_on
for d in dunst mako swaync; do
pgrep -x "$d" >/dev/null 2>&1 || continue
if confirm "$d is running and owns the notification service (MacShell shows notifications itself). Stop and disable it?" y; then
unit_on=0
if have systemctl && { systemctl --user is-enabled --quiet "$d.service" 2>/dev/null || systemctl --user is-active --quiet "$d.service" 2>/dev/null; }; then unit_on=1; fi
if [ "$unit_on" = 1 ]; then systemctl --user disable --now "$d.service" >/dev/null 2>&1 || true; fi
pkill -x "$d" >/dev/null 2>&1 || true
sleep 0.3
if pgrep -x "$d" >/dev/null 2>&1; then warn "$d is still running: stop it by hand (systemctl --user disable --now $d)"
else ok "$d stopped"; fi
[ "$unit_on" = 1 ] || say " $d was not started by systemd: remove it from your Hyprland autostart as well"
else
warn "$d keeps the notification service: MacShell cannot show notifications until it is stopped (systemctl --user disable --now $d)"
fi
done
for d in waybar hyprpanel; do
pgrep -x "$d" >/dev/null 2>&1 || continue
warn "$d is running: MacShell has its own menu bar, they overlap. Remove $d from your Hyprland autostart."
if confirm "Quit $d for this session now?" n; then pkill -x "$d" >/dev/null 2>&1 || true; fi
done
return 0
}
# does this Hyprland config start MacShell? (directly, or through the generated macshell.lua module)
autostart_present() { # autostart_present <config file>
local f="$1" m="$HYPR_DIR/macshell.lua" pat="macshell-start|(qs|quickshell)[[:space:]]+(-c|--config)[[:space:]]+$NAME"
grep -Eq "$pat" "$f" 2>/dev/null && return 0
if grep -Eq "require[[:space:]]*\\(?[[:space:]]*[\"']macshell[\"']" "$f" 2>/dev/null && [ -f "$m" ] && grep -Eq "$pat" "$m" 2>/dev/null; then
return 0
fi