Created
May 23, 2021 06:20
-
-
Save ldiebold/953a9c126af7b60a30bb3e143f081fd6 to your computer and use it in GitHub Desktop.
Autokey Script Examples - Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from subprocess import call | |
call(['google-chrome', 'https://cdn.materialdesignicons.com/4.7.95/']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter script code | |
import subprocess | |
from subprocess import call | |
def winexists(target): | |
for line in subprocess.check_output(['wmctrl', '-l', '-x']).splitlines(): | |
window_name = line.split(None, 3)[2].decode() | |
if window_name == target: | |
return True | |
return False | |
if winexists("google-chrome.Google-chrome"): | |
window.activate("google-chrome.Google-chrome", switchDesktop=True, matchClass=True) | |
else: | |
call(['google-chrome']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter script code | |
import subprocess | |
from subprocess import call | |
def winexists(target): | |
for line in subprocess.check_output(['wmctrl', '-l', '-x']).splitlines(): | |
window_name = line.split(None, 3)[2].decode() | |
if window_name == target: | |
return True | |
return False | |
if winexists("terminator.Terminator"): | |
window.activate("terminator.Terminator", switchDesktop=True, matchClass=True) | |
else: | |
call(['terminator', '-f', '--working-directory=/home/luke/code']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enter script code | |
import subprocess | |
from subprocess import call | |
def winexists(target): | |
for line in subprocess.check_output(['wmctrl', '-l', '-x']).splitlines(): | |
window_name = line.split(None, 3)[2].decode() | |
if window_name == target: | |
return True | |
return False | |
if winexists("code.Code"): | |
window.activate("code.Code", switchDesktop=True, matchClass=True) | |
else: | |
call(['code']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you encounter error in terminal script for Ubuntu (Gnome) try the following code
Enter script code
import subprocess
from subprocess import call
def winexists(target):
for line in subprocess.check_output(['wmctrl', '-l', '-x']).splitlines():
window_name = line.split(None, 3)[2].decode()
if window_name == target:
return True
return False
if winexists("gnome-terminal-server.Gnome-terminal"):
window.activate("gnome-terminal-server.Gnome-terminal", switchDesktop=True, matchClass=True)
else:
call(['gnome-terminal', '--working-directory=/home/prashant/www'])