Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (3) </ 1 2 [3] >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Dialog helper, Bash scripting guidance needed.< Next Oldest | Next Newest >
mikshaw Offline

Group: Members
Posts: 4856
Joined: July 2004
Posted: Oct. 16 2007,23:54 QUOTE

I'd say /usr/lib, /usr/local/lib, or somewhere in /opt

I mention /opt because this is DSL, and /opt is the only systemwide directory that is both writable by default and suitable for application files.

Back to top
Profile PM WEB 
Zucca Offline

Group: Members
Posts: 524
Joined: Feb. 2006
Posted: Oct. 17 2007,09:29 QUOTE

Here's an example how I use this dialoghelper in my Gentoo system.
This is a .bashrc file of my root account:
Code Sample

# If user is not in screen session AND file $HOME/.noscreen does not exist...
if [ -z `echo "$TERM" | grep screen` ] && [ ! -f "$HOME/.noscreen" ]

 # Ask user if he/she wants to start/continue a screen session.
 if source /usr/local/lib/dialoghelper && D_BACKTITLE="Starting a root session..." D_TITLE="Question" yesnoDialog "Start/Continue a screen session?"

   # Retach screen or start new screen session.
   # Also run 'clear' after screen exit for security.
   # Yes. It's a long line. It could be more neat, but I'm lazy.

   screen -dr && clear && exit \
   || ps -U `whoami` -u `whoami` | grep screen > /dev/null \
   && echo -e "\nProblems starting screen. Now running offscreen. :(" \
   || screen && clear && exit \
   || echo -e "\nCould not start screen. Do you have screen installed and is screen in your $PATH?"
 # No else here. Do nothing if user chose not to start or continue screen session.

 # Otherwise tell user that $HOME/.noscreen is present or he/she just opened a new screen window.
 # Yes. A long line again.
 test -f "$HOME/.noscreen" && test -z `echo "$TERM" | grep screen` \
 && echo -e "File $HOME/.noscreen exist, no screen startup.\n run 'screen' to start new screen session, or 'screen -dr' to continue previous session."


# Show user the $TERM and tell that it's a new window.
# (I myself wanted to see this in every new screen window.)
echo $TERM | grep "screen" > /dev/null \
&& echo -e "New screen window opened.\nTerminal: $TERM" && sleep 1s \
|| echo -e "Root session opened offscreen.\nTerminal: $TERM"
# I added a one sec pause there to show user that the new window
# was _just_ opened. Useless... Maybe.

# Next line is just to load aliases
# I have same aliases for my root account.;)
test -f "/home/zucca/.aliases" && source /home/zucca/.aliases

echo -e "Ready.\n"

# I hope you can read how this script works.;)

Why I made this script is that I sometimes forget to start screen session. If I happen to start a long process in X terminal it will be killed if I close it or exit X (for those who are unfamiliar with screen:all processes started inside screen session will not be terminated even if you close your X terminal). This script really makes me to remember to start screen session. ;)
It's one of the most useful scripts I have made for myself. At least I think it's really neat. ;P

Before there was no choice not to start screen when logged as root now, with help of dialoghelper, there is. Of course you could do that without dialog... ;) But this is just simple example of the use of dialoghelper.
I'll be adding new features to it and compability with DSL's whiptail too.

Do you have it? -
Back to top
11 replies since Oct. 03 2007,13:35 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (3) </ 1 2 [3] >/
reply to topic new topic new poll
Quick Reply: Dialog helper

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code