aboutsummaryrefslogtreecommitdiff
path: root/.config/polybar/scripts/polybar_wrapper
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2022-11-16 16:28:29 +0200
committersrdusr <trevorgray@srdusr.com>2022-11-16 16:28:29 +0200
commit23015965a4cecbd7a15049f0239fed4cdf540248 (patch)
tree497d48b86e8f0f5e7b09cd0a7150c7f3a7579d50 /.config/polybar/scripts/polybar_wrapper
parent6c42a0ae74a91e8c8a2fd65911e4a498555f2952 (diff)
downloaddotfiles-23015965a4cecbd7a15049f0239fed4cdf540248.tar.gz
dotfiles-23015965a4cecbd7a15049f0239fed4cdf540248.zip
Added polybar
Diffstat (limited to '.config/polybar/scripts/polybar_wrapper')
-rwxr-xr-x.config/polybar/scripts/polybar_wrapper92
1 files changed, 92 insertions, 0 deletions
diff --git a/.config/polybar/scripts/polybar_wrapper b/.config/polybar/scripts/polybar_wrapper
new file mode 100755
index 0000000..901bb28
--- /dev/null
+++ b/.config/polybar/scripts/polybar_wrapper
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+DIR=$(dirname $(realpath $0))
+
+WINDOW_ID_CONKY=/tmp/conky_window_id
+WINDOW_ID_TOP=/tmp/polybar_top_window_id
+WINDOW_ID_EXPANDED=/tmp/polybar_expanded_window_id
+
+conky_launch() {
+ # Hacky X11 magic to make Conky appear above polybar
+ killall conky
+ # xdotool search can't find Conky's window but fortunately Conky outputs it
+ conky -c ~/.config/conky/config 2> /tmp/conky_out
+ # Extract the hex window id from Conky's output
+ HEX=$(awk '/drawing to created window/ {print $NF}' /tmp/conky_out | tr -d '()' | awk -Fx '{print $2}')
+ WIN_ID=$(( 16#$HEX )) # convert to decimal
+ xdotool windowunmap $WIN_ID
+ echo $WIN_ID > $WINDOW_ID_CONKY
+}
+
+polybar_launch() {
+ killall polybar
+
+ polybar top &
+ xdotool search --sync --pid $! > $WINDOW_ID_TOP
+
+ polybar expanded &
+ xdotool search --sync --pid $! > $WINDOW_ID_EXPANDED
+
+ bar_collapse
+}
+
+launch() {
+ # Temporarily disable conky until I update the config
+ # conky_launch
+ # sleep 0.2
+ polybar_launch
+}
+
+bar_expand() {
+ xdotool windowmap $(cat $WINDOW_ID_EXPANDED)
+ xdotool windowunmap $(cat $WINDOW_ID_TOP)
+}
+
+bar_collapse() {
+ xdotool windowunmap $(cat $WINDOW_ID_EXPANDED)
+ xdotool windowmap $(cat $WINDOW_ID_TOP)
+}
+
+rofi_open() {
+ options_close
+ bar_expand &
+ rofi -modi run -show run
+ bar_collapse
+}
+
+drun_open() {
+ bar_expand &
+ rofi -theme drun -modi drun -show drun -drun-categories Custom
+ bar_collapse
+}
+
+search_open() {
+ options_close
+ bar_expand &
+ rofi -theme window -modi window -show window
+ bar_collapse
+}
+
+options_open() {
+ bar_expand
+ $DIR/rofi_option_menu
+ bar_collapse
+ # echo "open" > /tmp/polybar_side_panel_state
+ # ID_CONKY=$(cat $WINDOW_ID_CONKY)
+ # xdotool windowmap $ID_CONKY
+ # xdotool windowraise $ID_CONKY
+ # ~/.config/i3/scripts/music_player show_applet
+}
+
+case "$1" in
+ rofi)
+ rofi_open;;
+ search)
+ search_open;;
+ drun)
+ drun_open;;
+ options)
+ options_open;;
+ launch)
+ launch;;
+esac