Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 21 Oct 2014, 13:18
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
ROX-Filer: Closing all windows at once
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 3 Posts_count   Goto page: 1, 2, 3 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Thu 05 Jun 2014, 22:37    Post_subject:  ROX-Filer: Closing all windows at once
Sub_title: The fastest way to clean-up desktops
 

Sorry for a trivial suggestion. This closes all ROX windows on all desktops at once:
Code:
rox -D /

My problem is that I keep opening ROX-Filer windows and never bother to close them. Pretending that I'll reuse them later they get buried and abandoned, and when I run out of desktop space, I move on to the next clean desktop to open new windows until this desktop is messed up....well, I guess I'm not organized. Above code helps me to get back to a clean slate to start over again.

EDIT 1
On special request and in all its ugliness, the code to close all ROX windows on the current desktop at once:
Code:
D=$(echo "`wmctrl -d`" | grep "\*" | grep -o "^[0-9]*");R=$(echo -n "`wmctrl -lx`" | awk -F"[ .]+" '{if ($2=='$D' && $3=="ROX-Filer") print $1}');for i in $R;do wmctrl -ic $i;done
Requires wmctrl (included in every decent repository).

EDIT 2
This closes <any program> windows on all desktops at once.
The active window determines the windows to close. E.g if the currently active window belongs to the program mtPaint, this window and all other mtPaint windows will be closed.
Code:
#!/bin/sh
ACTIVE_WID="$(xprop -root | sed -n 's/^_NET_ACTIVE_WINDOW(WINDOW): window id # //p')"
ACTIVE_WNAME="$(xprop -id $ACTIVE_WID | sed -n 's/^.*WM_CLASS(STRING) = "//p' | sed 's/".*$//')"
Xdialog --yesno "Close all $ACTIVE_WNAME windows on ALL desktops?" 0 0 || exit
R=$(echo -n "`wmctrl -lx`" | awk -F"[ .]+" '{if ($3=="'"$ACTIVE_WNAME"'") print $1}')
for i in $R;do wmctrl -ic $i;done


Before someone asks...this will close <any program> windows on the current desktop :
Code:
#!/bin/sh
ACTIVE_WID="$(xprop -root | sed -n 's/^_NET_ACTIVE_WINDOW(WINDOW): window id # //p')"
ACTIVE_WNAME="$(xprop -id $ACTIVE_WID | sed -n 's/^.*WM_CLASS(STRING) = "//p' | sed 's/".*$//')"
Xdialog --yesno "Close all $ACTIVE_WNAME windows on current desktop?" 0 0 || exit
ACTIVE_DT="$(xprop -root | sed -n 's/^_NET_CURRENT_DESKTOP(CARDINAL) = //p')"
R=$(echo -n "`wmctrl -lx`" | awk -F"[ .]+" '{if ($2=='$ACTIVE_DT' && $3=="'"$ACTIVE_WNAME"'") print $1}')
for i in $R;do wmctrl -ic $i;done



________________________________________

Edited_times_total
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Thu 05 Jun 2014, 22:39    Post_subject:  

good to know. thanks, Mochi.

...what's the command to close only those on the current desktop? (i tried lowercase d on a hunch but no dice.)
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Fri 06 Jun 2014, 23:32    Post_subject:  

Puppus Dogfellow wrote:
...what's the command to close only those on the current desktop?
Not possible. Type rox -h for a list of all command line options.
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Sat 07 Jun 2014, 00:02    Post_subject:  

MochiMoppel wrote:
Puppus Dogfellow wrote:
...what's the command to close only those on the current desktop?
Not possible. Type rox -h for a list of all command line options.


thanks for the tip--easier to do panels with that info.
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Sat 07 Jun 2014, 03:13    Post_subject:  

MochiMoppel wrote:
Puppus Dogfellow wrote:
...what's the command to close only those on the current desktop?
Not possible. Type rox -h for a list of all command line options.


if that wmctrl program can call/identify each window of a program running on each desktop, and i think this is a fraction of what it can do, it can then close/minimize/maximize those windows. probably tile or cascade them as well. i see you know how to make the gtk stuff--wouldn't surprise me to find you've disproven your assertion within two weeks. Wink

you just write the script and list it as a dependency is all (although much of this is contingent upon the idea that i did not misread what wmctrl is all about).


of course, that's a bit more involved than discovering that command...
Sad
Smile

(hope that doesn't make you feel put upon. many thanks for the many improvements you've made to my favorite OS.)
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Mon 09 Jun 2014, 01:21    Post_subject:  

Puppus Dogfellow wrote:
wouldn't surprise me to find you've disproven your assertion within two weeks. Wink

Would surprise me to be proven wrong that early. Smile I stand by my claim that it's impossible with a (rox) or any other single command. But of course if you bring in heavy artillery like wmctrl you can shoot almost any window. See top post.
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Mon 09 Jun 2014, 07:06    Post_subject:  

MochiMoppel wrote:
Puppus Dogfellow wrote:
wouldn't surprise me to find you've disproven your assertion within two weeks. Wink

Would surprise me to be proven wrong that early. Smile I stand by my claim that it's impossible with a (rox) or any other single command. But of course if you bring in heavy artillery like wmctrl you can shoot almost any window. See top post.


very nice.
Laughing

...

Mochi, would swapping out "ROX-Filer" in
Code:

D=$(echo "`wmctrl -d`" | grep "\*" | grep -o "^[0-9]*");R=$(echo -n "`wmctrl -lx`" | awk -F"[ .]+" '{if ($2=='$D' && $3=="ROX-Filer") print $1}');for i in $R;do wmctrl -ic $i;done


for "[application of choice]" make this code do the same for all correctly named programs?

anyway, tested and confirmed to work well with Rox.

Thanks, Mochi.

edit: to test the theory, i swapped out "Rox-Filer" for "mtpaint" and clicking the script closed all the open mtpaint windows on the active desktop.

this could prove helpful for me, especially with regards to xpad; those things really tend to pile up.

Very Happy

update: i have now dragged symlinks to four versions of the script (swapping out "rox-filer" for leafpad, xpad, sakura, and mtpaint) which, when added to the original cr (close all rox windows on active desktop), gives me five new convenient terminal commands: cl, cx, cr, cm, cs (which closes itself).

great stuff.

....

here's wmctrl-1.07-6_i386.pet for anyone who wants it--i think it was originally put together by jemimah.

edit: wmctrl-1.07-6_i386.pet was made by lithpr

Edited_times_total
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Thu 12 Jun 2014, 05:45    Post_subject:  

Puppus Dogfellow wrote:
would swapping out "ROX-Filer" in ...
for "[application of choice]" make this code do the same for all correctly named programs?
You figured it out already, but for the record: You can find the correct name when you run xprop. Click on a window of the program of your interest and check the output in the terminal. E.g. when you click on a mtPaint window, check for the line that reads WM_CLASS(STRING) = "mtpaint", "Mtpaint". The first of the 2 names is the one used by the script.
Quote:
cs (which closes itself).
??? Sakura opens only one instance, why would you need a script to close it?
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Thu 12 Jun 2014, 06:16    Post_subject:  

MochiMoppel wrote:
Puppus Dogfellow wrote:
would swapping out "ROX-Filer" in ...
for "[application of choice]" make this code do the same for all correctly named programs?
You figured it out already, but for the record: You can find the correct name when you run xprop. Click on a window of the program of your interest and check the output in the terminal. E.g. when you click on a mtPaint window, check for the line that reads WM_CLASS(STRING) = "mtpaint", "Mtpaint". The first of the 2 names is the one used by the script.
Quote:
cs (which closes itself).
??? Sakura opens only one instance, why would you need a script to close it?


sakura's a button on my taskbar on one set up and a menu item on another--the terminals pile up at times as each click's a window and not a tab.
i think i was over using it (relative to rarely using the terminal at all) to test it out and play around with the customization features...and launch my panels and shortcuts... anyway, xprop seems like it will come in as handy as xev, which i just recently came across, so--thanks.


i seem to have run into some sort of snag on my precise 5.5. install--none of those little shortcuts work at the moment:
Code:
# cs
Cannot get current desktop properties. (_NET_CURRENT_DESKTOP or _WIN_WORKSPACE property)
awk: {if ($2== && $3=="sakura") print $1}
awk:           ^ syntax error
awk: {if ($2== && $3=="sakura") print $1}
awk:                          ^ syntax error
# cr
Cannot get current desktop properties. (_NET_CURRENT_DESKTOP or _WIN_WORKSPACE property)
awk: {if ($2== && $3=="ROX-Filer") print $1}
awk:           ^ syntax error
awk: {if ($2== && $3=="ROX-Filer") print $1}
awk:                             ^ syntax error
#




thankfully, the other one (rox -D /) still does--i've come to rely on it quite a bit...
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Thu 12 Jun 2014, 07:23    Post_subject:  

Puppus Dogfellow wrote:
i seem to have run into some sort of snag on my precise 5.5. install-
Did it work before? What awk version (command awk --version )? I tested with 3.1.8
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Thu 12 Jun 2014, 10:04    Post_subject:  

MochiMoppel wrote:
Puppus Dogfellow wrote:
i seem to have run into some sort of snag on my precise 5.5. install-
Did it work before? What awk version (command awk --version )? I tested with 3.1.8


Code:
# awk --version
GNU Awk 3.1.8


worked in precise 5.5 up until an x-server restart. works fine on precise 561 and 571.

...

any other commands that can be substituted in and out of the script? minimize, maximize, restore...what else can you do with all windows of a type?...

it'd be nice to get that working again, but this installation's picked up a problem or two over the months...the problem could be related to whatever caused me to have to restart the xserver in the first place--rox hangs on me if i click the Open With menu. the built in open withs are fine and dragging to applications works fine, and none of the default or set run actions have been affected, but at some point that stopped working correctly....

other than that, i have no idea why it stopped working or what else out of the ordinary took place around the time it quit.

Confused
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Thu 12 Jun 2014, 10:36    Post_subject:  

Puppus Dogfellow wrote:
any other commands that can be substituted in and out of the script?
Type wmctrl -h
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Sun 15 Jun 2014, 02:07    Post_subject:  

I added 2 options to the original post, which should provide sufficient flexibility. The scripts determine the window ID of the currently active window, then based on the window ID retrieve the proper program name and lastly use wmctrl to build a list all windows belonging to this program, the basis for the following "close" action.
Back to top
View user's profile Send_private_message 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 609
Location: nyc

PostPosted: Mon 16 Jun 2014, 00:04    Post_subject:  

MochiMoppel wrote:
I added 2 options to the original post, which should provide sufficient flexibility. The scripts determine the window ID of the currently active window, then based on the window ID retrieve the proper program name and lastly use wmctrl to build a list all windows belonging to this program, the basis for the following "close" action.


cool. gave each version a shortcut key; both are working very well, even on the installation that was having problems with the other version of the current desktop script. thanks for this, MochiMoppel.

...also work well with panel and jwm menu...and as desktop icons...

how do you activate them from the terminal? they close their filer or terminal window when activated with those methods.
Back to top
View user's profile Send_private_message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 425
Location: Japan

PostPosted: Mon 16 Jun 2014, 21:47    Post_subject:  

Puppus Dogfellow wrote:
how do you activate them from the terminal?
Why do you want to do that? That's not the way the script is meant to be used - unless you want the terminal windows to commit suicide.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 3 Posts_count   Goto page: 1, 2, 3 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1028s ][ Queries: 11 (0.0033s) ][ GZIP on ]