swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
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
#!/bin/bash
# omarchy:summary=Set and remember the power profile for AC or battery use
# omarchy:args=[autodetect|ac|battery] [power-saver|balanced|performance]
action="${1:-autodetect}"
requested_profile="${2:-}"
usage() {
echo "Usage: omarchy-powerprofiles-set [autodetect|ac|battery] [power-saver|balanced|performance]" >&2
exit 1
}
(( $# <= 2 )) || usage
case "$action" in
autodetect)
# Use the same signal as the shell (UPower.onBattery) so every entry point
# saves and restores the profile under the same ac/battery key.
if [[ $(busctl get-property org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower OnBattery 2>/dev/null) == "b true" ]]; then
action=battery
else
action=ac
fi
;;
ac | battery) ;;
*) usage ;;
esac
mapfile -t profiles < <(omarchy-powerprofiles-list)
profile_available() {
[[ " ${profiles[*]} " == *" $1 "* ]]
}
state_dir="${OMARCHY_POWERPROFILES_STATE_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/omarchy/powerprofiles}"
state_file="$state_dir/$action"
if [[ -n $requested_profile ]]; then
profile_available "$requested_profile" || {
echo "Power profile is not available: $requested_profile" >&2
exit 1
}
profile="$requested_profile"
elif [[ -r $state_file ]]; then
profile=$(<"$state_file")
fi
if [[ -z ${profile:-} ]] || ! profile_available "$profile"; then
if [[ $action == "ac" ]] && profile_available performance; then
profile=performance
else
profile=balanced
fi
fi
powerprofilesctl set "$profile" || exit
if [[ -n $requested_profile ]]; then
mkdir -p "$state_dir"
printf '%s\n' "$requested_profile" >"$state_file"
fi