mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2024-12-22 17:28:01 +00:00
Add script to switch window states between active/minimize and use it when clicking Spotify module
This commit is contained in:
parent
6e6445203c
commit
7a6d7ca172
@ -4,7 +4,7 @@ killall -q polybar
|
|||||||
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
|
||||||
|
|
||||||
export TERMINAL_CMD="tilix --profile orange --new-process -e"
|
export TERMINAL_CMD="tilix --profile orange --new-process -e"
|
||||||
export WM_CONTROL="wmctrl -a"
|
export WM_CONTROL="$(dirname $0)/scripts/switch_window_state"
|
||||||
|
|
||||||
for monitor in $(polybar --list-monitors | cut -d":" -f1); do
|
for monitor in $(polybar --list-monitors | cut -d":" -f1); do
|
||||||
export MONITOR=$monitor
|
export MONITOR=$monitor
|
||||||
|
@ -18,6 +18,7 @@ def get_spotify_song():
|
|||||||
title = metadata['xesam:title']
|
title = metadata['xesam:title']
|
||||||
|
|
||||||
window_title = artist + ' - ' + title
|
window_title = artist + ' - ' + title
|
||||||
|
|
||||||
output = "%{A1:$WM_CONTROL '" + window_title + "' &:}" + window_title + "%{A-}"
|
output = "%{A1:$WM_CONTROL '" + window_title + "' &:}" + window_title + "%{A-}"
|
||||||
except dbus.DBusException as e:
|
except dbus.DBusException as e:
|
||||||
if (e.get_dbus_message() == f'The name {bus_name} was not provided by any .service files'):
|
if (e.get_dbus_message() == f'The name {bus_name} was not provided by any .service files'):
|
||||||
|
22
.config/polybar/scripts/switch_window_state
Executable file
22
.config/polybar/scripts/switch_window_state
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
[[ -z $1 ]] && exit 1
|
||||||
|
|
||||||
|
active_window=$(xdotool getactivewindow)
|
||||||
|
window=$(xdotool search --name "$1")
|
||||||
|
[[ $? -ne 0 ]] && exit 1
|
||||||
|
|
||||||
|
if [[ $active_window == $window ]]; then
|
||||||
|
xdotool windowminimize $window
|
||||||
|
else
|
||||||
|
xdotool windowactivate $window
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user