-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolybar.launch.sh
More file actions
executable file
·52 lines (42 loc) · 1.46 KB
/
Copy pathpolybar.launch.sh
File metadata and controls
executable file
·52 lines (42 loc) · 1.46 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
#!/bin/bash
set -eu
find_power_supply() {
local requested_type="$1"
local device
for device in /sys/class/power_supply/*; do
[[ -r "${device}/type" ]] || continue
if [[ "$(<"${device}/type")" == "${requested_type}" ]]; then
basename "${device}"
return 0
fi
done
return 1
}
find_backlight() {
local device
for device in /sys/class/backlight/*; do
[[ -d "${device}" ]] || continue
basename "${device}"
return 0
done
return 1
}
POLYBAR_BATTERY="${POLYBAR_BATTERY:-$(find_power_supply Battery || true)}"
POLYBAR_ADAPTER="${POLYBAR_ADAPTER:-$(find_power_supply Mains || true)}"
POLYBAR_BACKLIGHT="${POLYBAR_BACKLIGHT:-$(find_backlight || true)}"
polybar_modules_right=()
[[ -n "${POLYBAR_BATTERY}" && -n "${POLYBAR_ADAPTER}" ]] \
&& polybar_modules_right+=(battery)
polybar_modules_right+=(filesystem)
[[ -n "${POLYBAR_BACKLIGHT}" ]] && polybar_modules_right+=(backlight)
polybar_modules_right+=(pulseaudio memory cpu wlan eth date systray)
POLYBAR_MODULES_RIGHT="${polybar_modules_right[*]}"
export POLYBAR_ADAPTER POLYBAR_BACKLIGHT POLYBAR_BATTERY POLYBAR_MODULES_RIGHT
if [[ "${1:-}" == "--print-env" ]]; then
printf 'POLYBAR_BATTERY=%s\n' "${POLYBAR_BATTERY}"
printf 'POLYBAR_ADAPTER=%s\n' "${POLYBAR_ADAPTER}"
printf 'POLYBAR_BACKLIGHT=%s\n' "${POLYBAR_BACKLIGHT}"
printf 'POLYBAR_MODULES_RIGHT=%s\n' "${POLYBAR_MODULES_RIGHT}"
exit 0
fi
exec polybar main