How to activate most recently focused app window in xfce4/xfwm4?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I use my function keys for specific applications (F1 chrome, F2 terminal, etc). I have a script bound to a shortcut key to activate the right application, and that works, but it doesn't activate the most-recently-focused window. The script lists windows with wmctrl -lx which seems to list windows by reverse-creation order. Is there any way to ask for or keep track of the order specific windows are activated so I can script "activate the most recent terminal window"?
Alternately, it seems if I was able to get the window stack order maintained by xfwm4 (which it uses when you cycle through windows), that seems like it would solve my problem as well but I don't see a command line interface to get at that window stack order.
x11 xfce wmctrl
add a comment |Â
up vote
0
down vote
favorite
I use my function keys for specific applications (F1 chrome, F2 terminal, etc). I have a script bound to a shortcut key to activate the right application, and that works, but it doesn't activate the most-recently-focused window. The script lists windows with wmctrl -lx which seems to list windows by reverse-creation order. Is there any way to ask for or keep track of the order specific windows are activated so I can script "activate the most recent terminal window"?
Alternately, it seems if I was able to get the window stack order maintained by xfwm4 (which it uses when you cycle through windows), that seems like it would solve my problem as well but I don't see a command line interface to get at that window stack order.
x11 xfce wmctrl
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I use my function keys for specific applications (F1 chrome, F2 terminal, etc). I have a script bound to a shortcut key to activate the right application, and that works, but it doesn't activate the most-recently-focused window. The script lists windows with wmctrl -lx which seems to list windows by reverse-creation order. Is there any way to ask for or keep track of the order specific windows are activated so I can script "activate the most recent terminal window"?
Alternately, it seems if I was able to get the window stack order maintained by xfwm4 (which it uses when you cycle through windows), that seems like it would solve my problem as well but I don't see a command line interface to get at that window stack order.
x11 xfce wmctrl
I use my function keys for specific applications (F1 chrome, F2 terminal, etc). I have a script bound to a shortcut key to activate the right application, and that works, but it doesn't activate the most-recently-focused window. The script lists windows with wmctrl -lx which seems to list windows by reverse-creation order. Is there any way to ask for or keep track of the order specific windows are activated so I can script "activate the most recent terminal window"?
Alternately, it seems if I was able to get the window stack order maintained by xfwm4 (which it uses when you cycle through windows), that seems like it would solve my problem as well but I don't see a command line interface to get at that window stack order.
x11 xfce wmctrl
edited Apr 21 at 2:56
asked Apr 20 at 22:49
Peter Lyons
1741210
1741210
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
In a script, you could use wmctrl, xprop and awk to use the activation time that is maintained by the window manager. (See e.g. wm-spec 1.5). E.g., use a (multi-line) command line like the following:
W=$(wmctrl -l |
awk '$ ~ "Terminal" print $1;' | while read x ; do
echo "$x $(xprop -id $(xprop -id $x
| awk '$1 ~ /_NET_WM_USER_TIME/ print $NF'
)
| awk 'print $NF'
)" ;
done | awk '$2>t i=$1; t=$2 END print i'
)
In words:
- pass the
wmctrllist through a filtering to select the window ids of the named application ("Terminal" in the example above); then - pass this through (innermost)
xpropto get a (pretend) window id for the last usage time, and - using another (outer)
xpropto get that timestamp , which is the (single) property of the "pretend window" of the_NET_WM_USER_TIME_WINDOWof the original window; then - pass all the resulting id and timestamp lines through an
awkfilter that reports the id with the greatest timestamp.
This almost works but it seems some of my windows report_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?
â Peter Lyons
Apr 21 at 2:44
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
Maybe some windows hold the timestamp directly, without having the_NET_WM_USER_TIME_WINDOWproperty? The step 2-3 filtering doesn't handle that well.
â Ralph Rönnquist
Apr 21 at 3:00
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
In a script, you could use wmctrl, xprop and awk to use the activation time that is maintained by the window manager. (See e.g. wm-spec 1.5). E.g., use a (multi-line) command line like the following:
W=$(wmctrl -l |
awk '$ ~ "Terminal" print $1;' | while read x ; do
echo "$x $(xprop -id $(xprop -id $x
| awk '$1 ~ /_NET_WM_USER_TIME/ print $NF'
)
| awk 'print $NF'
)" ;
done | awk '$2>t i=$1; t=$2 END print i'
)
In words:
- pass the
wmctrllist through a filtering to select the window ids of the named application ("Terminal" in the example above); then - pass this through (innermost)
xpropto get a (pretend) window id for the last usage time, and - using another (outer)
xpropto get that timestamp , which is the (single) property of the "pretend window" of the_NET_WM_USER_TIME_WINDOWof the original window; then - pass all the resulting id and timestamp lines through an
awkfilter that reports the id with the greatest timestamp.
This almost works but it seems some of my windows report_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?
â Peter Lyons
Apr 21 at 2:44
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
Maybe some windows hold the timestamp directly, without having the_NET_WM_USER_TIME_WINDOWproperty? The step 2-3 filtering doesn't handle that well.
â Ralph Rönnquist
Apr 21 at 3:00
add a comment |Â
up vote
1
down vote
In a script, you could use wmctrl, xprop and awk to use the activation time that is maintained by the window manager. (See e.g. wm-spec 1.5). E.g., use a (multi-line) command line like the following:
W=$(wmctrl -l |
awk '$ ~ "Terminal" print $1;' | while read x ; do
echo "$x $(xprop -id $(xprop -id $x
| awk '$1 ~ /_NET_WM_USER_TIME/ print $NF'
)
| awk 'print $NF'
)" ;
done | awk '$2>t i=$1; t=$2 END print i'
)
In words:
- pass the
wmctrllist through a filtering to select the window ids of the named application ("Terminal" in the example above); then - pass this through (innermost)
xpropto get a (pretend) window id for the last usage time, and - using another (outer)
xpropto get that timestamp , which is the (single) property of the "pretend window" of the_NET_WM_USER_TIME_WINDOWof the original window; then - pass all the resulting id and timestamp lines through an
awkfilter that reports the id with the greatest timestamp.
This almost works but it seems some of my windows report_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?
â Peter Lyons
Apr 21 at 2:44
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
Maybe some windows hold the timestamp directly, without having the_NET_WM_USER_TIME_WINDOWproperty? The step 2-3 filtering doesn't handle that well.
â Ralph Rönnquist
Apr 21 at 3:00
add a comment |Â
up vote
1
down vote
up vote
1
down vote
In a script, you could use wmctrl, xprop and awk to use the activation time that is maintained by the window manager. (See e.g. wm-spec 1.5). E.g., use a (multi-line) command line like the following:
W=$(wmctrl -l |
awk '$ ~ "Terminal" print $1;' | while read x ; do
echo "$x $(xprop -id $(xprop -id $x
| awk '$1 ~ /_NET_WM_USER_TIME/ print $NF'
)
| awk 'print $NF'
)" ;
done | awk '$2>t i=$1; t=$2 END print i'
)
In words:
- pass the
wmctrllist through a filtering to select the window ids of the named application ("Terminal" in the example above); then - pass this through (innermost)
xpropto get a (pretend) window id for the last usage time, and - using another (outer)
xpropto get that timestamp , which is the (single) property of the "pretend window" of the_NET_WM_USER_TIME_WINDOWof the original window; then - pass all the resulting id and timestamp lines through an
awkfilter that reports the id with the greatest timestamp.
In a script, you could use wmctrl, xprop and awk to use the activation time that is maintained by the window manager. (See e.g. wm-spec 1.5). E.g., use a (multi-line) command line like the following:
W=$(wmctrl -l |
awk '$ ~ "Terminal" print $1;' | while read x ; do
echo "$x $(xprop -id $(xprop -id $x
| awk '$1 ~ /_NET_WM_USER_TIME/ print $NF'
)
| awk 'print $NF'
)" ;
done | awk '$2>t i=$1; t=$2 END print i'
)
In words:
- pass the
wmctrllist through a filtering to select the window ids of the named application ("Terminal" in the example above); then - pass this through (innermost)
xpropto get a (pretend) window id for the last usage time, and - using another (outer)
xpropto get that timestamp , which is the (single) property of the "pretend window" of the_NET_WM_USER_TIME_WINDOWof the original window; then - pass all the resulting id and timestamp lines through an
awkfilter that reports the id with the greatest timestamp.
answered Apr 21 at 1:31
Ralph Rönnquist
2,36738
2,36738
This almost works but it seems some of my windows report_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?
â Peter Lyons
Apr 21 at 2:44
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
Maybe some windows hold the timestamp directly, without having the_NET_WM_USER_TIME_WINDOWproperty? The step 2-3 filtering doesn't handle that well.
â Ralph Rönnquist
Apr 21 at 3:00
add a comment |Â
This almost works but it seems some of my windows report_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?
â Peter Lyons
Apr 21 at 2:44
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
Maybe some windows hold the timestamp directly, without having the_NET_WM_USER_TIME_WINDOWproperty? The step 2-3 filtering doesn't handle that well.
â Ralph Rönnquist
Apr 21 at 3:00
This almost works but it seems some of my windows report
_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?â Peter Lyons
Apr 21 at 2:44
This almost works but it seems some of my windows report
_NET_WM_USER_TIME: not found.. Any idea why some windows have this but others don't?â Peter Lyons
Apr 21 at 2:44
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
No idea, really. Maybe "compositing"? Particular application(s) that evade(s) (some) window management?
â Ralph Rönnquist
Apr 21 at 2:57
Maybe some windows hold the timestamp directly, without having the
_NET_WM_USER_TIME_WINDOW property? The step 2-3 filtering doesn't handle that well.â Ralph Rönnquist
Apr 21 at 3:00
Maybe some windows hold the timestamp directly, without having the
_NET_WM_USER_TIME_WINDOW property? The step 2-3 filtering doesn't handle that well.â Ralph Rönnquist
Apr 21 at 3:00
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f439037%2fhow-to-activate-most-recently-focused-app-window-in-xfce4-xfwm4%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password