Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm not sure if this is the right place for the topic but here goes:
I would like to execute a script that causes a (undecorated/minimal) window border to flash up once when it changes it's state from unfocused to focused. How would I accomplish that? Alternatively, how would I go about executing a similar (modified to change borders to red) when the battery level reaches x%? I have the script figured out, all I need is to use it in a script that detects a window's state and executes the other script when focused.
Alternatively, how would I go about executing a similar script (modified to change borders to red) when the battery level reaches x%?
this is totally impractical: changing window borders requires interacting with the window manager, most probably changing its theme.
forget it.
it's much more practical to simply pop up a big, fat, red warning when your battery is low.
for that, there's a number of solutions.
Ondoho: I probably should clarify that I use Spectrwm, not a themed window manager like Fluxbox, Gnome or such. Spectrwm doesn't use any themes and decorations, except for a simple border around the windows. Wmctrl is a nifty tool that makes it possible to change the color of the window borders from a script. I wrote such a script, which I shall call flash.sh, and it works as intended - change a window's border to white and back within two seconds. My problem is to figure out how to use flash.sh in a script that detects when a window becomes focused, and executes flash.sh *once*, then continues scanning for windows that change their state to focused.
The idea for a script to change all border colors to red when the laptop battery goes low is just that - another idea and not my main concern.
@ all: Please refrain from posting dismissive and discouraging replies based on your shotgun judgement.
Last edited by linuxlicious; 08-08-2016 at 03:21 AM.
Ondoho: I probably should clarify that I use Spectrwm, not a themed window manager like Fluxbox, Gnome or such. Spectrwm doesn't use any themes and decorations, except for a simple border around the windows. Wmctrl is a nifty tool that makes it possible to change the color of the window borders from a script. I wrote such a script, which I shall call flash.sh, and it works as intended - change a window's border to white and back within two seconds. My problem is to figure out how to use flash.sh in a script that detects when a window becomes focused, and executes flash.sh *once*, then continues scanning for windows that change their state to focused.
The idea for a script to change all border colors to red when the laptop battery goes low is just that - another idea and not my main concern.
@ all: Please refrain from posting dismissive and discouraging replies based on your shotgun judgement.
well than you found a solution, no?
also, you should have mentioned which wm you use.
i am not familiar with spectrwm, it is possible that it provides changing of border colors on the fly.
@ op: please refrain from wrongly interpreting emotional content into my posts. also please refrain from labeling my choice of phrase with dismissive terminology.
I realize that I may have overreacted, which may be due to built up frustration from past experiences. That being said, what did stop you from asking me about the DE/WM that I use and what I intend to use to accomplish my task? And to tell me to forget about it first thing, without even bothering to ask questions seemed out of line to me. That is what i refer to as a "shotgun judgement".
Back to topic - I only figured out part of the problem, the script that makes the border flash up with the help of wmctrl. What I'm asking help for is to include this script into another script that scans the desktop for any windows that become focused and then executes the other script to make the window border of that focused window flash once. I'm not so experienced in scripting, so I need some help with that.
Last edited by linuxlicious; 08-09-2016 at 04:36 PM.
I realize that I may have overreacted, which may be due to built up frustration from past experiences.
that's ok, happens to all uf us.
Quote:
That being said, what did stop you from asking me about the DE/WM that I use and what I intend to use to accomplish my task?
it is op's task to provide as much info as possible about their problem, not mine trying to dig out every last bit of relevant info.
and using a non-standard wm like spectrwm is definitely a piece of info one should provide when having a problem with window borders/events.
Quote:
I only figured out part of the problem, the script that makes the border flash up with the help of wmctrl. What I'm asking help for is to include this script into another script that scans the desktop for any windows that become focused and then executes the other script to make the window border of that focused window flash once.
you should look into the man pages of
wmctrl
xprop
xwininfo
xdotool
a short example script that i use to toggle a terminal window with mocp:
Code:
#!/bin/dash
xprop -id $(xdotool getwindowfocus) | grep -F 'MOC [' && exec xdotool key q
# if the window that currently has focus is mocp (determined by its window title
# - not an elegant solution), use the script to close the window (like pressing q
# on the keyboard) and exit.
wmctrl -R "MOC [" || exec urxvt -e mocp
# otherwise, move an existing mocp terminal window to the current desktop and give
# it focus. OR, failing that, start a new instance.
this is just meant as an example of what one can do with the utilities mentioned above.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.