summaryrefslogtreecommitdiff
path: root/gen_waybar_confs.sh
blob: b13d8d79976260496322b55fc862a99893851b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

WCLONG="$(crcparse WC)"
WC="$(basename "$WCLONG")"
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
if [ ! -f "$CONFIG/waybar/config-$WC" ]; then
  printf "$CONFIG/waybar/config-$WC waybar config does not exist!\n"
  exit 1
fi

OUTPUTS="$(wlr-randr | grep -B5 'Enabled: yes' | sed '/^\s\s*/d;/^--/d' | cut -d' ' -f1)"

[ -n "$OUTPUTS" -a -z "$(find "$CONFIG"/waybar -name "config-$WC-*")" ] && \
  rm -rf "$CONFIG/waybar/config-$WC-*"

echo "$OUTPUTS" | while read i; do
  sed 's/%%DISPLAY%%/'$i'/' "$CONFIG"/waybar/config-$WC > "$CONFIG"/waybar/config-$WC-$i
done