I need help creating a shell script to toggle between two commands.
When it is run command1
is executed then if it is run again it executes command2
and so on...
I need help creating a shell script to toggle between two commands.
When it is run command1
is executed then if it is run again it executes command2
and so on...
One good way of accomplishing this is for the script to create a blank "configuration file":
command1
.command2
.command1
.command2
.And so forth.
Here's a script that does that:
(As a complement to the main answer)
To make it display a message after running the commands, and also showing an icon - example for toggling touchpad off and on (source, also here):
(in the above commands
14
is a variable to be identified withxinput list
)You can write a file with your last command. Then when it is run again you read the file, and see which command was executed.