Terminal command with button

Using applications, configuring, problems
Post Reply
Message
Author
ip71sr
Posts: 23
Joined: Wed 04 Jan 2012, 21:23

Terminal command with button

#1 Post by ip71sr »

How to run a terminal command with a button?

I want to run the command for suspend (acpitool -s) with a button.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#2 Post by Flash »

By "button" do you mean a keyboard key, a button in a GUI or what?

ip71sr
Posts: 23
Joined: Wed 04 Jan 2012, 21:23

#3 Post by ip71sr »

This is great! :) Well, in the meanwhile I discovered that you can short this task with "Gexec execute a command" when you push the button :) Menu > Utility. How to do this operation shorter with an icon shortcut on the desk (or shortcut key)?

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#4 Post by GustavoYz »

If you're using OpenBox there are plenty of tutorials that explain how to bind an action to a combination of keys (or just one).
"Action" can easily be your script.
This is an example.

You can create a custom script.desktop file to make a desktop icon and lauch the script by double click.
I know there are apps for doing those files and creating your own, but you can just copy & edit one from /usr/share/applications.

ip71sr
Posts: 23
Joined: Wed 04 Jan 2012, 21:23

#5 Post by ip71sr »

GustavoYz wrote:If you're using OpenBox there are plenty of tutorials that explain how to bind an action to a combination of keys (or just one).
"Action" can easily be your script.
This is an example.
OpenBox is another window manager? I guess you have suggested that because in this default lightweight one it is not easy to make an shortcut for a command in the terminal.
You can create a custom script.desktop file to make a desktop icon and lauch the script by double click.
I know there are apps for doing those files and creating your own, but you can just copy & edit one from /usr/share/applications.
Can you describe this a little bit more? I opened one as txt but I do not know what and how to change it.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#6 Post by Karl Godt »

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Name=SHUTDOWN into RAM Sleep
Icon=wizard16.xpm
Comment=ACPI G1 S3 
Exec=acpitool -s
Terminal=false
Type=Application
Categories=X-DesktopApplets
GenericName=acpitool -s
and after that run
fixmenus
jwm -reload || jwm -restart
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

ip71sr
Posts: 23
Joined: Wed 04 Jan 2012, 21:23

#7 Post by ip71sr »

It works well, thank you.
I believe the next logical step would be how this task can be activated after a period of inactivity of the computer? :)

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#8 Post by Karl Godt »

Then look into the
/sbin/pup_event_frontend_d
file .
Somewhere near the end there should be some line like

Code: Select all

[ $MOUSECNT -gt $POWERTIMEOUT ] && wmpoweroff &
change that wmpoweroff & to whatever code you want ie acpitool -s &

Of course you need to putin the POWERTIMEOUT into the /etc/eventmanager file ie :
#this parameter is read by /sbin/pup_event_frontend_d...
#power-off PC if mouse inactive for this many minutes (0 means never)...
POWERTIMEOUT=60
Note : am not sure if the pup_event_frontend_d keeps running after wake up .

To check it run

Code: Select all

pidof pup_event_frontend_d 
in the console.

Note > Needs restartwm aka restart X server after making these changes to relaunch the pup_event_frontend_d .

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#9 Post by Flash »

Could this script be modified to do what you want?

ip71sr
Posts: 23
Joined: Wed 04 Jan 2012, 21:23

#10 Post by ip71sr »

It looks very nice. Than you!

@Karl Godt
"POWERTIMEOUT" can also be directly set in Puppy Event Manager but in this way it doesn't work.
Don't matter, the last script looks fine. (It was always boring with sleep during e.g. video in another distribution).

Post Reply