maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   osso_xterm toolbar shortcut (https://talk.maemo.org/showthread.php?t=16749)

ridgeback 2008-02-17 05:54

osso_xterm toolbar shortcut
 
Hi, I'm just starting to learn *nix systems in general. I find myself switching to root a lot, and would like to create a shortcut on the X Terminal toolbar. I created on called Gainroot and enter "sudo gainroot" as the command but that doesn't do anything. Can I not run commands like that? If not, what is it's purpose?

Thanks,
Mike

geneven 2008-02-17 06:12

Re: osso_xterm toolbar shortcut
 
It works for <ctrl>p to go back in command history.

Perhaps someone will tell us the syntax for other commands.

bunanson 2008-02-17 06:42

Re: osso_xterm toolbar shortcut
 
Would it be easier just to use the 'up' Dpad? Ctrl+p involves 4 key strokes - ctrl, command line, p, 'OK'.


bun

free 2008-02-17 11:14

Re: osso_xterm toolbar shortcut
 
Quote:

alias r='sudo gainroot'
put this in .profile
then to become root, type

r

You could also create an x resource to map it to hardware key although I didn't try

tobiasj 2008-02-17 13:01

Re: osso_xterm toolbar shortcut
 
what would also be nice is something along the lines of the "root terminal" menu item in desktop linux.

I can certainly understand why there isnt one from the get go, being well dangerous to the system and all. But certainly we should be able to add one somehow. I am going to start poking around and see what I can come up with. never occured to me before now, but that would very nice.

-John

sashabe 2008-02-17 13:16

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by free (Post 143534)
put this in .profile
then to become root, type

r

You could also create an x resource to map it to hardware key although I didn't try

Where to search for this file? I haven't found it in home and root directories. Or should it be created?

micampe 2008-02-17 15:20

Re: osso_xterm toolbar shortcut
 
use this command:
Code:

sh -c "sudo gainroot"

ridgeback 2008-02-17 15:57

Re: osso_xterm toolbar shortcut
 
Thanks for the replies everyone. micampe, I entered what you suggested as the value of the xTerm toolbar shortcut, but nothing happens when I click it. These shortcuts should be able to run terminal commands like that, right? I would definitely make one to fire up Hamachi if that were the case. Any ideas?

Thanks again,
Mike

ridgeback 2008-02-17 16:13

Re: osso_xterm toolbar shortcut
 
BTW, I was playing around with your suggestion, and if I entered "sh 1" or "sh -c 1", then 1 will be sent to the terminal. However, "sh 12" and "sh -c 12" don't send 12 to the terminal. Also, "sh "1"" and "sh -c "1"", with quotes around the 1, doesn't even send 1, like it will without the quotes.

Thanks,
Mike

free 2008-02-17 16:30

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by sashabe (Post 143555)
Where to search for this file? I haven't found it in home and root directories. Or should it be created?

create it yes

$HOME/.profile is executed on login shells
/home/user/.profile

free 2008-02-17 16:37

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by micampe (Post 143588)
use this command:
Code:

sh -c "sudo gainroot"

osso-xterm -e "sudo gainroot"

bunanson 2008-02-17 17:22

Re: osso_xterm toolbar shortcut
 
How do you do a series of commands using alias, not script? say, sudo gainroot, echo 'rebooting....', reboot.?

How do you transfer input parameters using alias, not script? say, leafpad, echo 'file?' #filename?

TIA,

bun

free 2008-02-17 17:39

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by bunanson (Post 143654)
How do you do a series of commands using alias, not script? say, sudo gainroot, echo 'rebooting....', reboot.?

That's not possible. sudo gainroot will open a new shell and then your alias is lost. Also on a security point of view, the user cannot interact with a root process. Which is good..
Quote:

How do you transfer input parameters using alias, not script? say, leafpad, echo 'file?' #filename?
Not possible also. Leafpad uses a widget which takes Xwindow input. If it would take command line input, then we could do something like
popen("leafpad") and then use the descriptor to write into it.

In this case, we have to create use input at X level. The only way that I know (I use it at work) is xreplay or xnee.
xreplay < "go_to_leafpad_window,click file, click open, type $filename, click ok"

Ugly but saved me for GUI locked app.

edit: I think the leafpad that I updated for OS2008 takes the filename as parameter, if this is specific to leafpad.

bunanson 2008-02-17 18:41

Re: osso_xterm toolbar shortcut
 
For the OP, here is a small script for putting a reboot button on your desktop, you do have to install osso-statusbar, (go http://www.gronmayer.com/it/index.php, choose your OS, and search for statusbar, pick the one version tschmidt v.0.6.1chinook1 if you are 2008OS, and use the green install button, the other button does not work), and copy the script to /home/user and make it executable by,

chmod +x /home/user/bunreboot.sh

you can always modify it to add your commands.

bun


bunreboot.sh:
__________________________________________________ ____
#!/bin/sh
if [ `id -u` != 0 ] ; then
exec sudo gainroot <<EOF
exec sh $0 $*
EOF
exit $?
fi
exec reboot
__________________________________________________ ______

earth2marsh 2008-02-18 05:26

Re: osso_xterm toolbar shortcut
 
Put this in as the value for your Toolbar shortcut:
Code:

s . u . d . o . KP_Space . g . a . i . n . r . o . o . t
(Note: the spaces around the dots/periods are important!)

tobiasj 2008-02-18 06:21

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by earth2marsh (Post 143927)
Put this in as the value for your Toolbar shortcut:
Code:

s . u . d . o . KP_Space . g . a . i . n . r . o . o . t
(Note: the spaces around the dots/periods are important!)

that works great thanks, but is there a way to have it "return" or enter at the end of the line in the shortcut?

-John

ridgeback 2008-02-18 06:24

Re: osso_xterm toolbar shortcut
 
So, does anyway know how to run shell commands from a toolbar shortcut?

earth2marsh 2008-02-18 07:09

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by tobiasj (Post 143944)
that works great thanks, but is there a way to have it "return" or enter at the end of the line in the shortcut?

Yes, add " . KP_Enter" to the end. Like this:
Code:

s . u . d . o . KP_Space . g . a . i . n . r . o . o . t . KP_Enter

earth2marsh 2008-02-18 07:13

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by ridgeback (Post 143948)
So, does anyway know how to run shell commands from a toolbar shortcut?

Same idea: ./hi.sh would be:
Code:

period . slash . h . i . period . s . h . KP_Enter
In general, use these codes where you need them, and be sure to put a period between each keystroke to stick them all together.

free 2008-02-18 09:08

Re: osso_xterm toolbar shortcut
 
well done bun, the exec function does the trick
I never think about it

But I don't understand the stuffs with the period. humm:confused:

earth2marsh 2008-02-18 13:18

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by free (Post 143979)
But I don't understand the stuffs with the period.

The periods are acting as operators to concatenate an expression of character literals in order to convince the toolbar settings dialog into accepting a longer string (the word "period" in the last example is used to get an actual "." keystroke returned by the shortcut).

So the dots (".") are glue between each individual element like a letter or character. Does that explain it?

tobiasj 2008-02-18 13:54

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by earth2marsh (Post 143959)
Same idea: ./hi.sh would be:
Code:

period . slash . h . i . period . s . h . KP_Enter
In general, use these codes where you need them, and be sure to put a period between each keystroke to stick them all together.

that worked great thanks! and the link is very helpful, it is exactly what I was looking for but didnt know what to 'call it' to search for it...

-John

ridgeback 2008-02-18 15:24

Re: osso_xterm toolbar shortcut
 
Thank you everyone for contributing! I'm think this knowledge will be very useful to a lot of people! Thanks Again!

Mike

Benson 2008-02-18 17:12

Re: osso_xterm toolbar shortcut
 
Anyone know if you can bind modifiers as well? Like ^K, and such.

qole 2008-05-06 22:48

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by Benson (Post 144159)
Anyone know if you can bind modifiers as well? Like ^K, and such.

This is an old post, and I just stumbled on it while searching for something else, but ^K is "<ctrl>k" in the Toolbar Shortcut maker. KP_Enter can be also entered as <ctrl>m ... it is one character shorter! :D

<ctrl>c is very useful, it breaks execution of a command-line app.

A very useful shortcut for me is:
Code:

y,<ctrl>m
It is useful because lots of command-line apps bug you by asking you to hit "Y" if you are sure you want to do something, and it is nice to just hit a toolbar button instead of pulling up the screen keyboard or whatever.

EDIT: A couple other useful ones: | (pipe) is "bar" and _ is "underscore". Both are a pain to type (at least for me) on the virtual keyboard.

EDIT2: Note that you don't need the " . " (space-period-space) between characters, just use a comma.

Benson 2008-05-06 23:48

Re: osso_xterm toolbar shortcut
 
Thanks so much!

(I find ^K helpful for JOE; I bound around it using F2, but that doesn't help when I telnet out to other machines... ^C, of course, is obviously good, but ^Z is better; you can always stop the job after suspending it.)

Wiki updated!

zzoomm 2009-01-22 21:49

Re: osso_xterm toolbar shortcut
 
thx guys

also, found how to Paste selected text: <shift>KP_Insert

enjoy!

luis 2009-04-14 19:41

Re: osso_xterm toolbar shortcut
 
Ok, late to the party, but:

1) how to do "Delete" "Home" (BOL) and "End" (EOL)? I tried lots of combinations...

2) I use bash 2.05b, and PgUp and PgDn do not work for me (they write a '~').

Thanks!
L.

bousch 2009-04-14 20:08

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by qole (Post 178613)

EDIT2: Note that you don't need the " . " (space-period-space) between characters, just use a comma.

You can also simply use a single space instead...

bousch 2009-04-14 20:31

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by luis (Post 279581)
Ok, late to the party, but:

1) how to do "Delete" "Home" (BOL) and "End" (EOL)? I tried lots of combinations...

2) I use bash 2.05b, and PgUp and PgDn do not work for me (they write a '~').

Thanks!
L.

These should work:
KP_Delete
KP_Home
KP_End

Don't know why PgUp and PgDn don't work for you but you could try
KP_Prior or KP_Page_Up
KP_Next or KP_Page_Down

luis 2009-04-14 21:15

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by bousch (Post 279596)
These should work:
KP_Delete
KP_Home
KP_End

Don't know why PgUp and PgDn don't work for you but you could try
KP_Prior or KP_Page_Up
KP_Next or KP_Page_Down

No, I tried those. All these just write a '~' on the screen for me... The only one that works is KP_Enter.

With 'sudo gainroot' the above work. But how to make it work for the normal user?

Thanks,
L.

Iridos 2009-05-07 05:51

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by luis (Post 279610)
No, I tried those. All these just write a '~' on the screen for me... The only one that works is KP_Enter.

I think they actually do work and just don't do what you expect.

You probably want <ctrl>a for "home" and <ctrl>e for "end" in a terminal that doesn't understand home/end
(ctrl-e actually only works as a shortcut, if I type it on the keyboard, that is a global shortcut for search).

If they work as root, I suppose that uses a different type of shell for you?

I.

bunanson 2009-05-30 12:37

Re: osso_xterm toolbar shortcut
 
I like the toolbar shortcuts. But I have problem in doing the special characters like
/ (slash)
\
& (KP_amber, it is a guess)
. (period)
| (bar)

Does anybody know or where can I look up for more? TIA,

Edit: found some of them in this thread.

bun

qwerty12 2009-05-30 12:58

Re: osso_xterm toolbar shortcut
 
Quote:

Originally Posted by bunanson (Post 292102)
I like the toolbar shortcuts. But I have problem in doing the special characters like
/ (slash)
\
& (KP_amber, it is a guess)
. (period)
| (bar)

Does anybody know or where can I look up for more? TIA,

Edit: found some of them in this thread.

bun

Hey,

http://inz.fi/blog/2007/01/24/more-o...erm-shortcuts/ is a good page to look at (albeit the file mentioned is very long!).

& is "ampersand" (without the quotes). I found it by looking in that file on that page and removing the "GDK_".

HTH

bunanson 2009-05-30 13:16

Re: osso_xterm toolbar shortcut
 
Thanks qwerty12, you are always fast. Just one thing pop into my mind, you are so good in searching, which does require to know the subject WELL in order to put in a good search, you really would be a good competitor to Google if you want challenge. Just a thought, and a big thank you for finding this. And it is good to see your new avatar too :-)

bun


All times are GMT. The time now is 16:28.

vBulletin® Version 3.8.8