[Solved] Executing a Script from a Keyboard Shortcut

Forum rules
Before you post please read this

[Solved] Executing a Script from a Keyboard Shortcut

Postby Josh117 on Mon Jan 16, 2012 2:06 am

Over the past few days, I have been looking for a way to make a script run after pressing a keyboard shortcut. After some searching online, I was not able to find a solution.

I want to be able to have a message box pop up that says "Linux is NOT Windows" whenever you press Ctrl-Alt-Del (because I like my computer to have personality :D).

This is my script:
Code: Select all
#!/bin/bash

zenity --warning --title='Ctrl-Alt-Del' --text='Linux is NOT Windows!'
exit 0


Then, I used the Commands plugin in Compiz to run the script and binding <Control><Alt>Delete to the command.

Unfortunately, this only resulted in every opened program to lock up for some reason...

I understand that there are some sources of error that could be the reason this does not work, such as Compiz doesn't allow this kind of thing, or I wrote the script wrong, and so on, but I do not know which one it is.

If someone could help me with this, it would be much appreciated.

Josh
Last edited by Josh117 on Tue Jan 17, 2012 6:57 pm, edited 1 time in total.
"If it ain't broke, you're not trying."
Josh117
Level 1
Level 1
 
Posts: 14
Joined: Sun Jul 24, 2011 12:31 am
Location: Canada

Linux Mint is funded by ads and donations.
 

Re: Executing a Script from a Keyboard Shortcut

Postby xenopeek on Mon Jan 16, 2012 5:03 am

Open "Keyboard Shortcuts" from the menu. Add a new shortcut. Give it some name, and type the full path to your script, like so:
Code: Select all
bash -c /home/somebody/somewhere/myscript.bash

Then find your shortcut by name again, at the bottom of the list in the main window. Click at the end to set the keyboard shortcut.
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14820
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Executing a Script from a Keyboard Shortcut

Postby Pilosopong Tasyo on Mon Jan 16, 2012 5:47 am

You can forgo the script and directly add the whole zenity line in the Command field. It's only a one-liner anyway. :wink:
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1137
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Executing a Script from a Keyboard Shortcut

Postby Josh117 on Tue Jan 17, 2012 6:55 pm

Thanks for the solutions; they both work wonderfully. Now I can't wait for a Windows user to fall into my trap...
"If it ain't broke, you're not trying."
Josh117
Level 1
Level 1
 
Posts: 14
Joined: Sun Jul 24, 2011 12:31 am
Location: Canada


Return to Scripts & Bash

Who is online

Users browsing this forum: mikecolley and 4 guests