1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2024-12-22 08:08:00 +00:00

Add script to switch window states between active/minimize and use it when clicking Spotify module

This commit is contained in:
Daniel Carrillo 2019-08-06 16:25:59 +02:00
parent 6e6445203c
commit 7a6d7ca172
3 changed files with 24 additions and 1 deletions

View File

@ -4,7 +4,7 @@ killall -q polybar
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
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
export MONITOR=$monitor

View File

@ -18,6 +18,7 @@ def get_spotify_song():
title = metadata['xesam:title']
window_title = artist + ' - ' + title
output = "%{A1:$WM_CONTROL '" + window_title + "' &:}" + window_title + "%{A-}"
except dbus.DBusException as e:
if (e.get_dbus_message() == f'The name {bus_name} was not provided by any .service files'):

View 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