-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.sh
More file actions
executable file
·68 lines (62 loc) · 2.74 KB
/
Copy paththeme.sh
File metadata and controls
executable file
·68 lines (62 loc) · 2.74 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
#!/usr/bin/env bash
# Show or change the look of your Helix Boot stick: its theme, icons, background and splash.
# The choice is kept on the stick, so a refresh doesn't undo it.
# ./theme.sh how it looks now, and what there is to choose from
# ./theme.sh --menu choose from numbered lists, with a preview
# ./theme.sh --theme midnight a preset theme (`off`: the plain one, Standby)
# ./theme.sh --icons off no icons (or `grey`, or an icon pack such as `badges`)
# ./theme.sh --background pic.jpg --dim 40 your own picture behind the menu, darkened
# ./theme.sh --splash pic.png your own picture before the menu (`off`: none)
# ./theme.sh --reset back to the default look
set -Eeuo pipefail
HERE=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=scripts/common.sh
source "$HERE/scripts/common.sh"
trap on_err ERR
HELIX="$HERE/helix"
usage() {
cat <<EOF
Usage: ./theme.sh [options]
With no options: shows the stick's look and the themes and icon packs to choose from.
Options:
--theme ID a preset theme, or "default" ("off": the plain one, Standby)
--icons ID "auto" (the theme's own style, the default), "logos", "grey", an icon
pack such as "badges", or "off" for none
--background PICTURE your own picture behind the menu ("theme": the theme's again)
--dim PERCENT darken that picture (0-90) so the menu stays readable
--splash PICTURE your own picture before the menu ("theme", "auto", or "off")
--reset back to the default look
--menu choose from numbered lists instead, with a preview
--preview FILE don't change the stick: write a picture of how the menu would look
--stick WHERE the stick's partition or mount point, if more than one is plugged in
--eject unmount when finished
-h, --help this help
EOF
}
eject=0 target='' args=()
while (($#)); do
case $1 in
--theme|--icons|--background|--dim|--splash|--preview) args+=("$1" "${2:?$1 needs a value}"); shift ;;
--reset|--json|--menu) args+=("$1") ;;
--stick) target=${2:?--stick needs a partition or mount point}; shift ;;
--eject) eject=1 ;;
-h|--help) usage; exit 0 ;;
*) usage; die "unknown option: $1" ;;
esac
shift
done
[[ " ${args[*]} " == *" --json "* ]] || banner "theme"
[[ $EUID -ne 0 ]] || die "run this as your normal user"
check_python
need lsblk util-linux
need findmnt util-linux
if [[ " ${args[*]} " == *" --json "* ]]; then
find_stick "$target" >/dev/null
else
find_stick "$target"
fi
"$HELIX" theme "$mnt" "${args[@]}"
if ((eject)) && [[ -n $part ]]; then
unmount_part "$part"
ok "Unmounted — safe to unplug."
fi