antiX-forum Forum Index antiX-forum
Forum for users of antiX linux. "Mean and Lean"
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Welcome
Welcome to antiX-forum.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

Application Focus

 
Post new topic   Reply to topic    antiX-forum Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
DJiNN



Joined: 26 Oct 2007
Posts: 262
Location: UK

PostPosted: Sat May 10, 2008 4:22 pm    Post subject: Application Focus Reply with quote

All credit for this goes to Urukrama. All that i have done is altered a few names in the original scripts to make them work with the apps i use. Smile

For the sake of brevity, THIS will explain what these scripts do and what "Application Focus" is all about. Once you've read it (it's only a few paragraphs) then you should know what the following scripts are and how to use them.

The original scripts are for Thunar & Terminal (gnome?) but i tend to use XFCE4-Term, RoxTerm, Thunar & PCmanFM, so i've modified the scripts to work with those apps. I've included the script for each app below. All you need to do is save each one to it's own file & call it whatever you like. I have prefixed all of mine with a "1" (ie: 1roxterm.sh - 1thunar.sh etc) and made the script file executable. Then it's just a case of adding the relevant code to the fluxbox menu like so:

Code:

         [exec] (1-PCmanFM) {~/.1pcmanfm.sh}
    [exec] (1-XFCE4-Term) {~/.1xfce4term.sh}
    [exec] (1-Thunar) {~/.1thunar.sh}
    [exec] (1-RoxTerm) {~/.1roxterm.sh}


and that's it. Now whenever you click on, say "PCmanFM" for instance, whatever desktop you happen to be on, PCmanFM will appear on THAT desktop, and it will always be available whatever desktop you're on. As you can imagine, this is really helpful on systems with a low amount of RAM. Smile

So here are the scripts:

FOR THUNAR:
Code:

#!/bin/sh

thunar_wm_class="thunar"
thunar_exec="thunar"

# no thunar started, so start one
if [ -z "`wmctrl -lx | grep thunar`" ]; then
    $thunar_exec &
else
    # search for existing thunars on current desktop
    current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
    thunar_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$thunar_wm_class" | cut -d ' ' -f 1`
    if [ -n "$thunar_on_this_desk" ]; then
        wmctrl -i -a $thunar_on_this_desk
    else
        # no thunars on current desktop, so open a new one
        wmctrl -x -R $thunar_wm_class
    fi;
fi;


FOR PCMANFM:
Code:

#!/bin/sh

pcmanfm_wm_class="pcmanfm"
pcmanfm_exec="pcmanfm"

# no pcmanfm started, so start one
if [ -z "`wmctrl -lx | grep pcmanfm`" ]; then
    $pcmanfm_exec &
else
    # search for existing pcmanfm on current desktop
    current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
    pcmanfm_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$pcmanfm_wm_class" | cut -d ' ' -f 1`
    if [ -n "$pcmanfm_on_this_desk" ]; then
        wmctrl -i -a $pcmanfm_on_this_desk
    else
        # no pcmanfm's on current desktop, so open a new one
        wmctrl -x -R $pcmanfm_wm_class
    fi;
fi;


FOR ROXTERM:
Code:

#!/bin/sh

terminal_wm_class="roxterm"
terminal_exec="roxterm"

# no terminal started, so start one
if [ -z "`wmctrl -lx | grep roxterm`" ]; then
    $terminal_exec &
else
    # search for existing terminals on current desktop
    current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
    term_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$terminal_wm_class" | cut -d ' ' -f 1`
    if [ -n "$term_on_this_desk" ]; then
        wmctrl -i -a $term_on_this_desk
    else
        # no terminals on current desktop, so just open a new one
        wmctrl -x -R $terminal_wm_class
    fi;
fi;


FOR XFCE4-TERM:
Code:

#!/bin/sh

terminal_wm_class="Terminal"
terminal_exec="xfce4-terminal"

# no terminal started, so start one
if [ -z "`wmctrl -lx | grep terminal`" ]; then
    $terminal_exec &
else
    # search for existing terminals on current desktop
    current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
    term_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$terminal_wm_class" | cut -d ' ' -f 1`
    if [ -n "$term_on_this_desk" ]; then
        wmctrl -i -a $term_on_this_desk
    else
        # no terminals on current desktop, so just open a new one
        wmctrl -x -R $terminal_wm_class
    fi;
fi;


I have tested all of these & they work just fine and have made a big difference to my system and the way that i work.

Enjoy. Smile
Back to top
View user's profile Send private message
anticapitalista
Site Admin


Joined: 11 Sep 2007
Posts: 1026
Location: Greece

PostPosted: Sat May 10, 2008 5:02 pm    Post subject: Reply with quote

Nice tip DJiNN.

Does it work with rox-filer rather than thunar or pcmanfm?

OK, yes it does. Here is the script.
Code:

#!/bin/sh

rox_wm_class="rox"
rox_exec="rox"

# no rox started, so start one
if [ -z "`wmctrl -lx | grep rox`" ]; then
    $rox_exec &
else
    # search for existing rox on current desktop
    current_desk=`wmctrl -d | grep '*' | cut -d ' ' -f 1`
    rox_on_this_desk=`wmctrl -lx | grep "$current_desk[ ]*$rox_wm_class" | cut -d ' ' -f 1`
    if [ -n "$rox_on_this_desk" ]; then
        wmctrl -i -a $rox_on_this_desk
    else
        # no rox on current desktop, so open a new one
        wmctrl -x -R $rox_wm_class
    fi;
fi;


In some ways it might be even better to open the script via hotkey (fluxbox/keys) rather than through the fluxbox menu.
eg
Mod1 h :ExecCommand ./rox.sh
_________________
Philosophers have interpreted the world in many ways; the point is to change it.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DJiNN



Joined: 26 Oct 2007
Posts: 262
Location: UK

PostPosted: Sat May 10, 2008 6:20 pm    Post subject: Reply with quote

Thanks anti. Smile

I would imagine that it would work with most things, which is really cool. On Urukrama's blog he does go on to say about using key bindings with the scripts. Unfortunately, i just can't get the MOD4 key to work in fluxbox on any of my machines. When ever i press the MOD4 key (Win Key?) with another key that, according to the keys file, should trigger something, nothing happens.

Hmmm, just tried it, and actually some of them do work. MOD1 (The Alt key?) does seem to work, so something like MOD1 TAB will flip between windows (Apps) etc. It seems to be ONLY the MOD4 key that's NOT recognised.

But yeah, the scripts are great, and i shall add that Rox one to my list. Smile
Back to top
View user's profile Send private message
DJiNN



Joined: 26 Oct 2007
Posts: 262
Location: UK

PostPosted: Sat May 10, 2008 6:37 pm    Post subject: Reply with quote

Stranger still, i just added your script for Rox Filer to a MOD1 F5 keybinding, but everytime i press it, it just brings up Roxterm instead! LOL!! How odd is that? All the other scripts work fine though.
Back to top
View user's profile Send private message
anticapitalista
Site Admin


Joined: 11 Sep 2007
Posts: 1026
Location: Greece

PostPosted: Sat May 10, 2008 7:13 pm    Post subject: Reply with quote

Hmm, sure you've got the name of the script file right?
_________________
Philosophers have interpreted the world in many ways; the point is to change it.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DJiNN



Joined: 26 Oct 2007
Posts: 262
Location: UK

PostPosted: Sat May 10, 2008 7:52 pm    Post subject: Reply with quote

I think so. I've checked every letter, and checked whether it's executable etc, and everything seems to be OK. I'll get to the bottom of it eventually. Smile

One thing you could help me with though, is the location of the xmodmap.conf file. I thought it was in /etc but it doesn't seem to be anywhere on the system. Yet when i do an xmodmap -pm it brings up the settings etc, of which there are NONE for the MOD4 key, that's why i want to add it into the xmodmap.conf, or should i be looking for another file?
Back to top
View user's profile Send private message
anticapitalista
Site Admin


Joined: 11 Sep 2007
Posts: 1026
Location: Greece

PostPosted: Sat May 10, 2008 8:37 pm    Post subject: Reply with quote

I think it should be .xmodmaprc and placed in your home directory.
There isn't one by default in antiX.

http://lassauge.free.fr/cygwin/.xmodmaprc
_________________
Philosophers have interpreted the world in many ways; the point is to change it.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DJiNN



Joined: 26 Oct 2007
Posts: 262
Location: UK

PostPosted: Sat May 10, 2008 8:42 pm    Post subject: Reply with quote

That's great. Thanks for that anti. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    antiX-forum Forum Index -> Tips and Tricks All times are GMT + 3 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Chest


Powered by phpBB
Hosted by FreeForums.org