I want to run terminal or focus it by pressing F1 button. What I've tried to implement it:
Add custom shortcut to gnome keyboard settings with such command.
wmctrl -s 4 && pgrep terminator || nohup terminator > /dev/null &`
wmctrl -s 4
switches screen,- then
pgrep terminator
checks if terminal already running, nohup terminator > /dev/null &
runs terminal if it is not.
The screen switches right, but terminal not opens.
Place the command (as above) to executable
*.sh
file and specify absolute path to it in shortcut settings.
All the same.Run above command in another terminal.
Works as expected. (screen switches, terminator opens)Run script with above command:
#!/bin/zsh wmctrl -s 4 && pgrep terminator || nohup terminator > /dev/null &
Not works again. Screen switches but terminator window not appears. Also there is pid number in the terminal after running the script.
It seems like the terminator closes after lunching for some reason.
What I should do to create shortcut with such actions?
pgrep terminator
always fails. Trypgrep -f terminator || nohup terminator
instead. That's becauseterminator
is a python program so what you see inpgrep
ispython
, notterminator
. – terdon♦ Jan 14 '17 at 18:04pgrep terminator
works as expected. It returns pid of running terminator instance. – German Lashevich Jan 14 '17 at 18:07