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 Sun 26 Oct 2014, 03:13
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Wizards should always be able to run from console without X
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 2 of 3 Posts_count   Goto page: Previous 1, 2, 3 Next
Author Message
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Sun 21 Nov 2010, 11:59    Post_subject:  

This seems to work:

Code:

#!/bin/sh
VAR="$(echo $(tty) | cut -d: -f1 )"
if [ "$VAR" = "not a tty" ]; then
yaf-splash -text "clicked"
else
yaf-splash -text "in console"
fi
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Sun 21 Nov 2010, 22:13    Post_subject:  

Code:
#!/bin/sh
[ ! $DISPLAY ] && echo NoX && exit || \
[ $(tty) ] && yaf-splash -text Terminal && exit || \
yaf-splash -text Gui
or if you don't care if it is in a terminal you can simply use
Code:
#!/bin/sh
[ $DISPLAY ] && yaf-splash -text X && exit || echo NoX
the second will be part of bashbox as a function called message
Code:
message() {
[ $DISPLAY ] && yaf-splash -text "$@" && exit || echo "$@"
}
I also use this to pick what dialog to use:
Code:
[ $DISPLAY ] && DIALOG=Xdialog || DIALOG=dialog

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Mon 22 Nov 2010, 02:13    Post_subject:  

Maybe I am missing the point (and excuse me if I am) but:
jpeps: I cant get your code to work from console.
technosaurus: cli/dialog-scripts run from console wont be able to run with your switches - but it will tell me why...

jpeps code indicate that there can be different output from tty so I rephrase my code suggestion to:
Code:

#!/bin/sh
[ -n $DISPLAY ] && [ "$(tty | grep not)" ] && exec rxvt -e sh -c $0
echo "I am forced to be spawned from a shell...
and I could call cli, dialog, Xdialog, yaf-splash,
GTK-dialog or xmessage-content, dependent on which
environment I am in - instead of just using echo..."
read DUMMY
Back to top
View user's profile Send_private_message Visit_website 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Mon 22 Nov 2010, 04:19    Post_subject:  

Yes - they will be able to run in the console - I tested it
I was just simplifying the logic so that the code is more readable,

It simply echoes "NoX" from the console (that is the code)
In a terminal it displays "Terminal" using yaf-splash
From a gui it displays "Gui" using yaf-splash

feel free to insert whatever necessary code at those points
The only reason I can see bothering with tty is if you think that Xdialog
would not be available. Then you would set DIALOG="rxvt -e dialog"
or something like that.

I made an automatic gui generator in bashbox that just accepts a set of inputs - it would be fairly simple to build a cli interface to it.

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Mon 22 Nov 2010, 06:42    Post_subject:  

technosaurus:
Embarassed you are right Embarassed it works of course in console.

Quote:
The only reason I can see bothering with tty is if you think that Xdialog would not be available


That is what I am trying to say - quoting myself:

Quote:
Setup-wizards should as a minimum be able to run from shell without any GUI wrapped around it


I will change thread title to:
Wizards should always be able to run from shell/console without X...
Back to top
View user's profile Send_private_message Visit_website 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Mon 22 Nov 2010, 11:07    Post_subject:  

Quote:
goingnuts"

I will change thread title to:
Wizards should always be able to run from shell/console without


I agree with the end goal
everybody goes about it a different way Confused
I prefer a standard linux way that would work for most distros
removing all puppy code

one that installs packages
runs all the important set up scripts

that was the motive for suggesting slackwares
approach using pkgtool
as a well developed and practical working example
to use or just get good ideas from

before posting here in your thread
I spent many months digging into and re writing the code
doing a complete re write of over a thousand lines of code

while converting pkgtool from dialog to xdialog
I discovered some of the snags between syntax

if you make it for only one special puppy version
which is the trend its dead before it can mature

if you to make it more linux compatible
I would help

Joe

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4353

PostPosted: Mon 22 Nov 2010, 11:27    Post_subject:  

@gn
Running in the X terminal should be a user choice though. Some console based UIs would take a series of screens instead of a single interface. Many users would prefer that the "easier" interface come up when they quickly open a terminal and type in the name of utility XYZ. Having this method as default except on low-ram systems or if the user changes the value of USEGUIAPPSINTERM (or whatever)

@bb
I have done similar work with {X}dialog and for the workarounds of mismatched syntax,I had set up variables and to do something like:
$DIALOG (common_code_here) $DIALOGA$XDIALOGA ... $DIALOGZ$XDIALOGZ (more_common_code) 0 0

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Mon 22 Nov 2010, 11:31    Post_subject:  

going nuts:

I was testing Joe's script, clicking on programs from an icon vs from within a terminal loading gtkdialog3 or bacon apps where X is loaded; so [-n $DIALOG ] will always be true. Sorry for the muddle. Smile
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Mon 22 Nov 2010, 13:27    Post_subject:  

Thank you all for the feed back! Cool

This thread was started mainly to make a statement and if possible, make creators of wizards think: Will this wizard always work? What happens if I screw up my GTK/Xdialog/Xmessage/Yaf-splash etc.?
If X is broken only a few of Puppys setup-scripts will work.

Setup-scripts is an important content of an OS - why not make it robust and functional under the barest conditions?

big_bass:
Quote:

if you make it for only one special puppy version
which is the trend its dead before it can mature

if you to make it more linux compatible
I would help

I use the dialogfunctions.sh for my own purpose(=joy) - did not mean to create anything beyond that - only used it to make my point...but if it has any potential and the "more linux compatible" could be clarified for me...why not?

technosaurus
Quote:

Running in the X terminal should be a user choice though

Fully agree! I see no contradiction between robust code and user choice (or coded best choice). The long series of dialogs is old school and should only be visible when needed - it should not exclude fancy one-shot setup GUIs.

jpeps:
Quote:

Sorry for the muddle

I'm sorry - might have misused your example to promote my own statement... think [ -n $DISPLAY ] even might sometime give wrong result i console - maybe [ $DISPLAY ] is more secure?
Back to top
View user's profile Send_private_message Visit_website 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Mon 22 Nov 2010, 14:20    Post_subject:  

goingnuts wrote:

.. think [ -n $DISPLAY ] even might sometime give wrong result i console - maybe [ $DISPLAY ] is more secure?

Both work the same on this end, as does [ "$(tty | grep not)" ]
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Mon 22 Nov 2010, 16:10    Post_subject:  

jpeps: After exit to prompt from X I get:
"Im in second part..."
"Im in first part..."
running the below script:
Code:

#!/bin/sh
echo "Testing [ \$DISPLAY ]..."
if [ $DISPLAY ]; then
echo "Im in first part..."
else
echo "Im in second  part..."
fi

echo "Testing [ -n \$DISPLAY ]..."
if [ -n $DISPLAY ]; then
echo "Im in first part..."
else
echo "Im in second  part..."
fi

Question
Its been a long day but below code (fragment to use in top of dialogfunctions.sh) seems to work clicking icon in rox, run from rxvt or run from console:
Code:
TYPE="cli"      #dialog or cli
[ $(which dialog) ] && TYPE="dialog" && DIALOG=dialog
[ $(which Xdialog) ] && [ $DISPLAY ] && DIALOG=Xdialog
[ $DISPLAY ] && [ "$(tty | grep not)" ] && [ ! "${DIALOG}" = "Xdialog" ] && exec rxvt -e sh -c $0

where last line only there to take care of the rox-click...
Back to top
View user's profile Send_private_message Visit_website 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Mon 22 Nov 2010, 22:37    Post_subject:  

goingnuts wrote:
jpeps: After exit to prompt from X I get:
"Im in second part..."
"Im in first part..."
running the below script:
Code:

#!/bin/sh
echo "Testing [ \$DISPLAY ]..."
if [ $DISPLAY ]; then
echo "Im in first part..."
else
echo "Im in second  part..."
fi

echo "Testing [ -n \$DISPLAY ]..."
if [ -n $DISPLAY ]; then
echo "Im in first part..."
else
echo "Im in second  part..."
fi

Question


try
Code:

if [ -n "$DISPLAY" ]
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 781

PostPosted: Tue 23 Nov 2010, 01:18    Post_subject:  

jpeps:
YES!
"$DISPLAY" seems to be the only reliable of the four possible
($DISPLAY, ${DISPLAY}, "$DISPLAY" and "${DISPLAY}") with or without the -n...
Back to top
View user's profile Send_private_message Visit_website 
01micko


Joined: 11 Oct 2008
Posts: 7836
Location: qld

PostPosted: Sun 28 Nov 2010, 19:32    Post_subject:
Sub_title: NOX rescue pack
 

Hi guys

I'm putting together a rescue pack, based on some of the work you guys have done here.

It will contain nothing more than a script that will download and install elinks and weechat, both a good browser and chat client outside of X respectively. The script will run inside of X too.

The idea is, that if a noob (or whoever) crashes X, they can just type 'help-NOX' at the prompt and a dialog will open asking if they want to download and install the packages. Once installed, another dialog will open up asking if they want to browse or chat.

Where i'm at now is the installation. I guess I should try this, but do any of you know if a pet will install at console level using petget? (ok, just tried, it was doomed to fail...) If not I guess I could tarball the package and expand and merge.

One thing I noticed .. when someone types 'help' at the prompt I think you end up with bash help, not real good for a noob. Any ideas on how to override this?

Cheers

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send_private_message Visit_website 
upnorth


Joined: 11 Jan 2010
Posts: 262
Location: Wisconsin UTC-6 (-5 DST)

PostPosted: Sun 28 Nov 2010, 20:11    Post_subject: installpkg.sh  

Hi:
/usr/local/petget/installpkg.sh worked a couple months ago when i tried it.
I think it just takes an absolute path and package name as argument.

petget +package.pet may have worked at one time but now it demands gtk, but
petget -packagebasename worked for uninstalling.
Back to top
View user's profile Send_private_message Visit_website 
Display_posts:   Sort by:   
Page 2 of 3 Posts_count   Goto page: Previous 1, 2, 3 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
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.0953s ][ Queries: 12 (0.0050s) ][ GZIP on ]