You are not logged in.
Say, I have found target window with help of parsing 'wmctrl -l' output. Is it possible
1. to hide the window? I have tried (with wmctrl -e) to move the window outside a screen without success - some part of a window is always visible.
2. to detremine if the window is active or not?
I mean all these actions be used in script(s) binded to a key in rc.xml.
And more common question: is there some kind of interface to call OpenBox's actions in scripts?
Last edited by student975 (2011-04-23 22:30:34)
"I exist" is the best myth I know..
Offline
Please be a little clearer on what you are trying to do. I don't see the difference between iconifying a window and hiding a window off screen.
Without a panel, I can't see any evidence of a window when I iconify it. And Alt-Tab type switching allows me to bring it back. But without a panel, my first choice for app-hiding is to send it to a different desktop.
Or do you the want the effect of a virtual screen larger than your monitor or monitors? I think you can do that with xrandr and KMS, but I'm not sure.
Last edited by thisoldman (2011-04-23 20:47:47)
Offline
I'd want to have a script (binded to a key) for given concrete application with such pseudo-logic:
if (the app is running) {
if (the app has focus) {
make the app invisible:
- for all desktops
- for tint2
- for Alt-Tab
}
else
wmctrl -i -R appId
}
else {
start the app;
move to a given position;
}Have I success in clarifying my aim? ![]()
Last edited by student975 (2011-04-23 21:23:44)
"I exist" is the best myth I know..
Offline
Yes, "hiding" to dedicated desktop is an acceptable workaround (we still have unnecessary desktop during desktop ring cycling, but I rare cycle desktops). But the task to determine "is the app window active or not?" remains.
"I exist" is the best myth I know..
Offline
It seems I have found that trick to get active window id:
xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'So, I'll mark the topic as solved. Nevertheless I'll be happy to know about a trick to avoid additional desktop introducing.
"I exist" is the best myth I know..
Offline
You will find this forum thread interesting, https://bbs.archlinux.org/viewtopic.php?id=71789.
Offline
You could also use Xlib's XUnmapWindow. This will completely hide the window. In fact, the only way to bring it back is to call XMapWindow yourself.
Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.
Tu ne cede malis sed contra audentior ito
Offline
You could also use Xlib's XUnmapWindow. This will completely hide the window. In fact, the only way to bring it back is to call XMapWindow yourself.
Thanks, but atm It's too early (or late?) for me to dig in C code, I feel. Still fighting with bash
Have got working-as-expected scipt:
#!/bin/bash
CMD="lilyterm -t 4"
CTX=" - LilyTerm"
TMPDESKTOP=4
ID=$(wmctrl -l | grep "$CTX" | awk '{print $1}')
if [ -z $ID ] ; then
$CMD &
sleep 0.1
ID=$(wmctrl -l | grep "$CTX" | awk '{print $1}')
wmctrl -i -r $ID -e 0,300,0,-1,-1
else
ID10=$(calc $ID)
ACTIVE10=$(calc $(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'))
if [ $ID10 -eq $ACTIVE10 ] ; then
wmctrl -i -r $ID -t $TMPDESKTOP
else
wmctrl -i -R $ID
fi
fi
exit 0I'm sure it is awful. How to simplify/deuglify?
"I exist" is the best myth I know..
Offline
You will find this forum thread interesting, https://bbs.archlinux.org/viewtopic.php?id=71789.
Thanks, I'll dig in.
"I exist" is the best myth I know..
Offline
You will find this forum thread interesting, https://bbs.archlinux.org/viewtopic.php?id=71789.
Yes, xdotool is exatly that tool I have had lack. And it does just exactly those things BurntSushi has told about.
Thanks to all!
//----- lyrics -------
Oh... I must strain my imagination to overview capabilities all these tools bring to us ![]()
"I exist" is the best myth I know..
Offline
Here final script is which I use last days. The app is a lilyterm. The script is binded to F12. Behaviour:
1. If terminal
- is not started, or
- started, but hidden, or
- is opened on another desktop, or
- is opend on the current desktop, but is not focused,
you will get focused terminal on the current dektop.
2. If you have focused terminal, F12 just hide it ('unmap' in X terms).
In rc.xml I have decribed the app this way:
<application class="Lilyterm" name="lilyterm" type="normal">
<position force="yes">
<x>300</x>
<y>0</y>
</position>
<decor>no</decor>
<skip_pager>yes</skip_pager>
<!--
<skip_taskbar>yes</skip_taskbar>
-->
</application>As you can see, 'skip_taskbar' tag is commented out. The reason is: if you have got focused terminal, switched to another desktop and then switched back to first one, terminal's focus is lost.
The script itself ('xdotool key --window $ID "ctrl+shift+F1"' is just to switch to first lilyterm tab):
#!/bin/bash
TITLE="lilyx"
ID=$(xdotool search --name $TITLE)
if [ -z "$ID" ] ; then
lilyterm -t 3 -T $TITLE &
sleep 0.5
ID=$(xdotool search --name $TITLE)
xdotool windowfocus $ID
xdotool key --window $ID "ctrl+shift+F1" &
else
ACTIVE=$(calc $(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'))
MAPSTATE=$(xwininfo -id $ID | grep "Map State:" | awk '{print $3}')
if [[ $MAPSTATE == "IsViewable" ]] && [ $ID -eq $ACTIVE ] ; then
xdotool windowunmap $ID
else
FOUND=$(wmctrl -l | grep "$TITLE")
if [ -z "$FOUND" ] ; then
xdotool windowmap --sync $ID
xdotool windowfocus $ID
else
wmctrl -i -R $ID
fi
fi
fi"I exist" is the best myth I know..
Offline