View previous topic :: View next topic |
Author |
Message |
Sir Alaran Apprentice


Joined: 11 Dec 2003 Posts: 182 Location: KSJC
|
Posted: Thu Jan 15, 2004 1:49 am Post subject: Useful script for bringing up the terminal |
|
|
This is my first (useful) script, so don't expect anything fancy. Combined with a keybinding this will allow you to open and close the terminal program of your choice using that otherwise usless Windows(c) key.
Code: |
#!/bin/bash
terminalactivated=`pidof TERMINAL_PROGRAM`
if [ $terminalactivated ]
then
kill `pidof TERMINAL_PROGRAM`
else
terminalactivated = 1
TERMINAL_PROGRAM
fi
|
Remember to replace TERMINAL_PROGRAM with the terminal program you'd like to use.
I prefer a transparent Eterm that stays at the bottom of the screen, but this is Linux, and you are free to choose what you will.
For GNOME users:
Click "Applications->System Tools->Configuration Editor"
Then in the tree view find apps/metacitiy/global_keybindings.
Set "run_command_1" to "Super_L" (the left Windows(c) key)
Then go to apps/metacitiy/global_keybindings and set the value of
"command_1" to "bash PATH_TO_SCRIPT" Something like "/home/you/bin/terminalscript"
My apologies, but I don't know how to set this up with other WMs. Maybe someone will post a way to do this with KDE Fluxbox, etc... *hint hint*
Have fun. _________________ D is awesome.
Textadept is my friend. |
|
Back to top |
|
 |
cuban Guru


Joined: 23 Aug 2003 Posts: 448 Location: Houston, TX
|
Posted: Thu Jan 15, 2004 5:25 am Post subject: |
|
|
In fluxbox just edit .fluxbox/keys and add this:
Code: |
None Mod4 :ExecCommand /path/to/script
|
I personally set the menu key to just open aterm. I wouldn't want to hit it by accident and kill all my terminals. _________________ Tell your ISP to support SPF/SASL AUTH (http://spf.pobox.com) today! |
|
Back to top |
|
 |
Sir Alaran Apprentice


Joined: 11 Dec 2003 Posts: 182 Location: KSJC
|
Posted: Thu Jan 15, 2004 7:40 am Post subject: |
|
|
Upon further testing (which I really should have done earlier) I have discovered that this only works when you only want to use one terminal at a time. When more than one of the terminal is open, pressing the key will just open another one (for reasons I know nothing about). Anyways, this will do the trick if you want a terminal that appears and dissapears with a key press. _________________ D is awesome.
Textadept is my friend. |
|
Back to top |
|
 |
ang n00b

Joined: 30 Jan 2003 Posts: 29
|
Posted: Thu Jan 15, 2004 9:18 am Post subject: |
|
|
I rather use screen -R -DD when launching terminals like this, for tabbed terminal browsing.
Code: |
${TERMINAL} -e screen -R -DD
|
an aterm example:
Code: |
aterm -tr +sb -bg white -sh 50 -rv -fade 80 -tint blue -e screen -R -DD
|
|
|
Back to top |
|
 |
Ari Rahikkala Guru

Joined: 02 Oct 2002 Posts: 370 Location: Finland
|
Posted: Fri Jan 16, 2004 10:10 am Post subject: |
|
|
Sir Alaran wrote: | -- this only works when you only want to use one terminal at a time. When more than one of the terminal is open, pressing the key will just open another one (for reasons I know nothing about). |
pidof prints out a list of pids. test (the left square bracket character is an alias for test) expects a single expression as an argument (well, actually, it can do a lot more - read the man page). If pidof prints only one number, test can deal with it. However, any more than that causes a parse error.
A quick way (i.e. not necessarily the cleanest, but it worked when I tried it out on this system) to fix this is to use:
if [ -n "`pidof $TERMINAL_PROGRAM`" ]
This version checks if the string that pidof returns has nonzero length. This means that it works with any amount of returned pids.
...
Ah, did some research, found two different (and yes, probably cleaner) ways:
- using the -s flag for pidof, causing it to return only one pid
- using pidof's return code, like this:
if pidof $TERMINAL_PROGRAM > /dev/null 2>&1
You'll have to figure out the meanings of the return codes here yourself, all I can tell is that it works (the values of truths and falsehoods in the shell have left me a bit baffled, to be honest). The redirection at the end means "put stderr into stdout, and put stdout into the bit bucket" (in that order). _________________ <laurentius> gentoo linux?
<ari> Yesh.
<laurentius> they look horny |
|
Back to top |
|
 |
|
|
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
|
|