polybar: Make hardcoded paths dependant from XDG
Instead of hardcoding the paths of all the scripts, use env variables
that are set in launch.sh. This way the config also works with
XDG_CONFIG_HOME not set to ~/.config.
Sadly polybar only accepts references that stand on their own.
(So something like ${env:XDG_CONFIG_HOME:~/.config}/polybar/<script>
does not work.) Hence the mess with the associative array and the
variables for every module.
This commit is contained in:
@@ -106,7 +106,7 @@ ramp-13 =
|
|||||||
|
|
||||||
[module/battery-custom]
|
[module/battery-custom]
|
||||||
type = custom/script
|
type = custom/script
|
||||||
exec = ~/.config/polybar/scripts/battery.sh
|
exec = ${env:POLYBAR_BATTERY}
|
||||||
interval = 5
|
interval = 5
|
||||||
|
|
||||||
;#################################################
|
;#################################################
|
||||||
@@ -128,15 +128,15 @@ label = "%date% - %time%"
|
|||||||
|
|
||||||
[module/media]
|
[module/media]
|
||||||
type=custom/script
|
type=custom/script
|
||||||
exec = ~/.config/polybar/scripts/media.sh
|
exec = ${env:POLYBAR_MEDIA}
|
||||||
interval = 1
|
interval = 1
|
||||||
|
|
||||||
;#################################################
|
;#################################################
|
||||||
|
|
||||||
[module/vpn]
|
[module/vpn]
|
||||||
type = custom/script
|
type = custom/script
|
||||||
exec = ~/.config/polybar/scripts/running-vpn.sh
|
exec = ${env:POLYBAR_VPN}
|
||||||
click-left = ~/.config/polybar/scripts/pub-ipv4.sh &
|
click-left = ${env:POLYBAR_VPN_CLICK_LEFT}
|
||||||
interval = 5
|
interval = 5
|
||||||
|
|
||||||
;#################################################
|
;#################################################
|
||||||
@@ -156,13 +156,13 @@ label-disconnected = %{A1:gnome-terminal -x nmtui connect:} %ifname% disconnecte
|
|||||||
|
|
||||||
[module/bluetooth]
|
[module/bluetooth]
|
||||||
type = custom/script
|
type = custom/script
|
||||||
exec = ~/.config/polybar/scripts/bluetooth.sh
|
exec = ${env:POLYBAR_BLUETOOTH}
|
||||||
tail = true
|
tail = true
|
||||||
click-left = ~/.config/polybar/scripts/bluetooth.sh --toggle &
|
click-left = ${env:POLYBAR_BLUETOOTH_CLICK_LEFT}
|
||||||
|
|
||||||
;#################################################
|
;#################################################
|
||||||
|
|
||||||
[module/powermenu]
|
[module/powermenu]
|
||||||
type = custom/text
|
type = custom/text
|
||||||
content = %{A1:~/.config/rofi/powermenu.sh &:}%{T2}...%{T-}%{A}
|
content = ${env:POLYBAR_POWERMENU}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,21 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
|
XDG_CONF="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
|
BASE_DIR="$XDG_CONF/polybar"
|
||||||
|
|
||||||
|
declare -A module_flags
|
||||||
|
module_flags=(
|
||||||
|
[battery]="$BASE_DIR/scripts/battery.sh"
|
||||||
|
[bluetooth]="$BASE_DIR/scripts/bluetooth.sh"
|
||||||
|
[bluetooth_click_left]="$BASE/scripts/bluetooth.sh --toggle &"
|
||||||
|
[media]="$BASE_DIR/scripts/media.sh"
|
||||||
|
[powermenu]="%{A1:$XDG_CONF/rofi/powermenu.sh &:}%{T2}...%{T-}%{A}"
|
||||||
|
[vpn]="$BASE_DIR/scripts/vpn.sh"
|
||||||
|
[vpn_click_left]="$BASE_DIR/scripts/pub_ipv4.sh &"
|
||||||
|
)
|
||||||
|
for module in "${!module_flags[@]}"; do
|
||||||
|
export POLYBAR_${module^^}="${module_flags[$module]}"
|
||||||
|
done
|
||||||
|
|
||||||
# if there is no running instance
|
# if there is no running instance
|
||||||
if ! pgrep -ax polybar >/dev/null 2>&1; then
|
if ! pgrep -ax polybar >/dev/null 2>&1; then
|
||||||
@@ -9,7 +26,7 @@ if ! pgrep -ax polybar >/dev/null 2>&1; then
|
|||||||
export TRAY_POS=none
|
export TRAY_POS=none
|
||||||
[ "$m" != "$primary" ] || export TRAY_POS=right
|
[ "$m" != "$primary" ] || export TRAY_POS=right
|
||||||
export MONITOR="$m"
|
export MONITOR="$m"
|
||||||
polybar --reload -c "${XDG_CONFIG_HOME:-$HOME/.config}/polybar/config" main &
|
polybar --reload -c "$BASE_DIR/config" main &
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Polybar launched..."
|
echo "Polybar launched..."
|
||||||
|
|||||||
Reference in New Issue
Block a user