Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-01-05 10:21:06

squalou
Member
Registered: 2011-08-14
Posts: 7

Change panel background depending of existence of fullscreen window

Hi,

I'd enjoy to tweak my panels a bit more, just for the fun.

I know how to change panels preferences with xconf-query, that's the easy part.
What I'm looking for would be a way to
- 'know' that a window has gone fullscreen / lost fullscreen status,
- then check if any window has a fullscreen status on monitor where panel is,
- depending on the result, adapt panel background.

The main missing parts for me are
-  the 'trigger an event' part : how could a program / script be notified of a WM event,
- the more elegant way to discover what are the fullscreen windows.

Anything else is apparently straightforward.

Any idea anyone ?


My target would be to have : transparent panel whenever nothing is fullscreen, black panel when something is fullscreen. Not very original I'm pretty sure I've seen it elsewhere, can't remember where.


thank you !

Offline

#2 2020-01-05 11:31:00

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,378

Re: Change panel background depending of existence of fullscreen window

If you are using xfce4-panel version 4.12, have a read through this thread.

And here is a version of that script for 4.14:

#!/bin/bash
# Description:	Darken the panel when a application goes full screen
# Requires: 	xprop xfce4-panel(4.13 or greater)
# Source:		https://forum.xfce.org/viewtopic.php?pid=52449

##################################
# Panel Properties > Appearance > Style
#	1. None (system color) will be the default dark color
#	2. Solid Color - set it to a fully transparent image
#	3. Optional: To get full transparency on the panel (no hover/active colors), 
#		add the following to ~/.config/gtk-3.0/gtk.css
#
#			/* transparent hover/active xfce4-panel */
#			.xfce4-panel.background button,
#			.xfce4-panel.background button.flat,
#			.xfce4-panel.background button:active, 
#			.xfce4-panel.background button:hover, 
#			.xfce4-panel.background button:active:hover, 
#			.xfce4-panel.background .tasklist button, 
#			.xfce4-panel.background .tasklist button.flat,
#			.xfce4-panel.background .tasklist button:active,
#			.xfce4-panel.background .tasklist button:hover, 
#			.xfce4-panel.background .tasklist button:active:hover
#			{
#				border-color: transparent;
#				background-color: transparent;
#				background-image: none;
#				box-shadow: none;
#				transition: none; 
#			}
#
#	4. Save the following script to an appropriate location
#		and make it executable
#	5. Create a User systemd service
#		a. Create the directory: mkdir -p ~/.config/systemd/user
#		b. Use the following service file (~/.config/systemd/user/panelcol.service)
#
#				[Unit]
#				Description=Set panel opacity
#				[Service]
#				ExecStart=path/to/script PANEL_NUM
#				Type=simple
#				[Install]
#				WantedBy=default.target
#
#			Note: PANEL_NUM is the number of the panel to adjust
#		c. enable the service: systemctl --user enable panelcol.service
#		d. start the service: systemctl --user start panelcol.service
#	6. Enjoy.

##################################

# don't change anything below here
PANEL_NUM=$1
CURR=0
while true
do
	MAX_FND=0
	for w in $(xprop -notype -root _NET_CLIENT_LIST | cut -d'#' -f2 | tr ',' '\n' | awk '{print $1}')
   	do 
                if [[ "$(xprop -id $w -notype _NET_WM_DESKTOP | cut -d' ' -f3)" -eq "$(xprop -root -notype _NET_CURRENT_DESKTOP | cut -d' ' -f3)" ]]
                then

		   if xprop -id $w _NET_WM_STATE | grep -E "MAXIMIZED_HORZ.*MAXIMIZED_VERT" > /dev/null 2>&1
		   then
			if xprop -id $w WM_STATE | grep -E "window state: Normal" > /dev/null 2>&1
			then
				MAX_FND=1
				break
			fi
		   fi
                fi
	done

	if [[ $MAX_FND -eq 1 && $CURR -eq 0 ]]
	then
		xfconf-query -n -c xfce4-panel -p /panels/panel-$PANEL_NUM/background-style -t int -s 0
		CURR=1			
	elif [[ $MAX_FND -eq 0 && $CURR -eq 1 ]]
	then
		xfconf-query -n -c xfce4-panel -p /panels/panel-$PANEL_NUM/background-style -t int -s 1
		CURR=0
	fi

	sleep 0.5s
	
done
exit 0

...instructions in the comments at the top of the script.

Offline

#3 2020-01-05 13:29:36

squalou
Member
Registered: 2011-08-14
Posts: 7

Re: Change panel background depending of existence of fullscreen window

thank you !

Offline

#4 2020-01-05 13:39:13

squalou
Member
Registered: 2011-08-14
Posts: 7

Re: Change panel background depending of existence of fullscreen window

in an ideal world, it wouldn't rely on 'sleep' infinite loop,
but then would require a more elaborate program to kick it on WM events.

Maybe I'll bind it to the keyboard shortcuts I use to move windows around, or something. Anyway, works like charm.

Offline

#5 2020-01-06 08:23:16

squalou
Member
Registered: 2011-08-14
Posts: 7

Re: Change panel background depending of existence of fullscreen window

Sidenote : the script approach does not work with multi-monitor, I'll have to dig a bit further to knwo on which monitor the panel actally is, and where fullscreen windows are.

Offline

#6 2020-01-06 12:09:33

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,378

Re: Change panel background depending of existence of fullscreen window

squalou wrote:

Sidenote : the script approach does not work with multi-monitor, I'll have to dig a bit further to knwo on which monitor the panel actally is, and where fullscreen windows are.

Yes, it was only designed for single monitor use. It needs to be tweaked for mulit-monitor use. Let me know if you come up with something.

Offline

Board footer

Powered by FluxBB