Ubuntu – How To Program A Bash Script That Presses A Certain Combination Of Keys

15.10bashkubuntuscriptsshortcut-keys

Please, i need someone to help me in making a very simple bash script. The job of this script is just to press a certain combination of keys on the keyboard.

My objective is to create a script that would turn off the Kubuntu desktop effects completely. The key combination for that is: "Left-ALT + Left-Shift + F12". I am aware that there is a widget that might do this job, but i am trying to learn how to accomplish it with a bash script.

I have tried to do an online search but i guess i was choosing the wrong set of keywords. I did not manage to reach a tutorial or a reference that would mention this task.

Thanks in advance for your help!

P.S: Any suggestions, references, notes, comments or tutorials would also be greatly be appreciated.

Best Answer

For those who wants to accomplish this task, please follow the steps below:

Create an empty file and write the following simple bash script inside:

#!/bin/bash
xdotool key alt+shift+F12

Save the file as ".sh" and make it executable.

You can add any set of keys and this tool can also allow you to automate the mouse. You can create very useful scripts with it if used properly.

Happy coding!


Credits: Special thanks to @muru for teaching me how to write this script.


Tutorial: http://manpages.ubuntu.com/manpages/trusty/en/man1/xdotool.1.html

Related Question