Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My way Implement fixed key #18

Open
Moanrisy opened this issue Oct 20, 2023 · 0 comments
Open

My way Implement fixed key #18

Moanrisy opened this issue Oct 20, 2023 · 0 comments

Comments

@Moanrisy
Copy link

I'm using autokey app on linux, basically it select VLC window then simulate keyboard press alt + ir

import subprocess

def focus_or_open_vlc():
    process = subprocess.Popen(['pgrep', '-f', 'vlc'], stdout=subprocess.PIPE)
    output, _ = process.communicate()
    if process.returncode == 0:
     # Vlc is already running, focus on the active Vlc window
     dolphin_windows = subprocess.check_output(['wmctrl', '-l', '-p']).decode().splitlines()
     for window in dolphin_windows:
         if any(pid in window for pid in output.decode().split()):
             window_id = window.split()[0]
             subprocess.Popen(['wmctrl', '-ia', window_id])
                         
             # Launch vlc-delete extension
             time.sleep(0.5)
             keyboard.send_keys("<alt>+ir")
             
             break
    else:
        # Dolphin is not running, so open a new instance
        subprocess.Popen(['/usr/bin/vlc', '--started-from-file', '/mnt/storage/Music/with-lyric/'])

focus_or_open_vlc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant