Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@davebrny
Last active June 27, 2019 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davebrny/9850223119c4ee55485dfae1fcbb8488 to your computer and use it in GitHub Desktop.
Save davebrny/9850223119c4ee55485dfae1fcbb8488 to your computer and use it in GitHub Desktop.
(autokey) - select a file to run in Wine
import getpass
import os.path
import subprocess
keyboard.send_keys("<ctrl>+c")
time.sleep(0.2)
str = clipboard.get_clipboard()
if "/.wine/" not in str: # if path is a native linux folder
user = getpass.getuser()
root = "/home/" + user
wine = root + "/.wine/drive_c/users/" + user
if root + "/Desktop/" in str:
str.replace(root + "/Desktop" , wine + "/Desktop")
elif root + "/Documents" in str:
str.replace(root + "/Documents", wine + "/My Documents")
elif root + "/Pictures" in str:
str.replace(root + "/Pictures" , wine + "/My Pictures")
elif root + "/Music" in str:
str.replace(root + "/Music" , wine + "/My Music")
elif root + "/Videos" in str:
str.replace(root + "/Videos" , wine + "/My Videos")
if os.path.isfile(str):
if str[-3:] == 'ahk':
ahk_path = "/home/dave/.wine/drive_c/users/dave/My Documents/autohotkey portable/AutoHotkeyU32.exe"
subprocess.Popen(["wine", ahk_path, str])
else:
subprocess.Popen(["wine", str])
'''
[script info]
version = 0.1
description = run a program in Wine
author = davebrny
source = https://gist.github.com/davebrny/9850223119c4ee55485dfae1fcbb8488
software = AutoKey 0.90.4 (Pop_OS 18.10)
'''
@davebrny
Copy link
Author

davebrny commented Jun 27, 2019

usage

  • set this script to run from a hotkey in Autokey
  • click on an .exe program in your file browser
  • press the hotkey to have it run in Wine

if you want to run an AutoHotkey script then add the full AutoHotkey.exe path to the ahk_path variable

normally you can only run programs that are somewhere in Wine's drive_c folder but with this script you can also run from the following native Linux folders and the paths will be swapped out so it runs the files in Wine's corresponding folders

/home/USER/Desktop
/home/USER/Documents
/home/USER/Pictures
/home/USER/Music
/home/USER/Videos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment