LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

"Always on top" indicator script for Openbox

Posted 11-16-2018 at 06:47 PM by the dsc
Updated 12-04-2018 at 08:36 PM by the dsc

May have some use outside of Openbox as well, I don't know. I have Openbox set up so the window focus will follow the mouse cursor, no need to click them to raise and so on, which I find usually convenient but sometimes it requires to toggle some windows to "always on top" in order to do some drag-and-drop operations and things like that. If I forget to do it, one of the windows will disappear below another and that's a bit annoying; sometimes I may have even toggled it, but toggled it to normal again, leading to some confusion.

So an "always on top" indication should be handy. The way I came up with it is to have it written on the title bar:

Code:
#!/bin/bash

indication=">>> ABOVE <<<      "

active=$(xprop -notype -root _NET_ACTIVE_WINDOW) 

xprop -id ${active##*\ } | grep _NET_WM_STATE_ABOVE && wmctrl -r :ACTIVE: -N "${indication} $(xdotool getwindowfocus getwindowname)" || wmctrl -r :ACTIVE: -N "$(xdotool getwindowfocus getwindowname | sed 's|'"${indication}"'||' )"
And the "toggle always on top" bindings on openbox' rc.xml should be along the lines of:

Code:
 <action name="ToggleAlwaysOnTop"></action>
        <action name="Execute"><command>aboveindicator</command></action>
Where "aboveindicator" is the name I saved the script, which is on $PATH, but one can give any name and put it anywhere, as long as the full path is given there.

It will only work when toggling it through Openbox, though, or in any other way where the script is also run and the window being toggled is also active. May also fail in Openbox if somehow one has bindings that toggle windows that aren't active, if that's possible.




Fails for window bundles using suckless' "tabbed". Once one clicks the window, it refreshes the titlebar. Actually fails on a more general manner, every time a program changes its title bar text, like when switching tabs. Well, better than nothing I guess.

But makes me reconsider something like somehow toggling a per-window shadow/glow or whatever. I'd not like to toggle transparency, which "unfortunately" is easy to do.

Code:
#!/bin/bash
active=$(xprop -notype -root _NET_ACTIVE_WINDOW) ; xprop -id ${active##*\ } | grep _NET_WM_STATE_ABOVE && transset -i ${active##*\ } 0.90 || transset -i ${active##*\ } 1.0
That's the most "reliable" indicator I can come up with right now...

But the script itself isn't even necessary. Just replace the script for transset -a -t 0.9 on openbox' rc.xml. The "-t" toggles between the given transparency and full opacity.



I think I've found a "standalone" compton solution
I already had compton just for transparency, but hadn't been using shadows for a while, so I thought maybe shading just the always-on-top windows could be a nice indicator. Apparently it can be done with these settings on .compton.conf:

Code:
shadow = true;

no-dock-shadow = true;		# Avoid drawing shadows on dock/panel windows.
no-dnd-shadow = true;		# Don't draw shadows on DND windows.
clear-shadow = true;		# Zero the part of the shadow's mask behind the window (experimental).
shadow-radius = 9;		# The blur radius for shadows. (default 12)
shadow-offset-x = -11;		# The left offset for shadows. (default -15)
shadow-offset-y = -7;		# The top offset for shadows. (default -15)


shadow-exclude = [
"! _NET_WM_STATE@:32a *= '_NET_WM_STATE_ABOVE'"

];
Not the entire config, just the non-commented shadow configurations, the "shadow exclude" being the key thing. The first excludes everything that is not ("!") above/always-on-top.

Aosd_cat is always on top by nature, so if one wants to exclude it: "class_i ?= 'libaosd'"
Posted in Uncategorized
Views 355 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 07:23 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration