Created
October 18, 2024 15:49
-
-
Save grafuls/59fb83347ce5266fee5be87bfc2dd40d to your computer and use it in GitHub Desktop.
Find a firefox window, scroll tabs till it finds a google meet one, press ctrl+d to unmute.
This file contains hidden or 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
#! /usr/bin/env python | |
import subprocess | |
from subprocess import CalledProcessError | |
import time | |
def get_active_window_title(): | |
try: | |
window_title = subprocess.check_output("xdotool getactivewindow getwindowname", shell=True).decode('utf-8').strip() | |
return window_title | |
except subprocess.CalledProcessError: | |
return None | |
def focus_or_open_chrome_meet(): | |
meet_title_fragment = "Meet - " | |
try: | |
window_list = subprocess.check_output("wmctrl -lx | grep -E 'firefox'", shell=True).decode('utf-8').strip().splitlines() | |
except CalledProcessError: | |
print("No firefox instance running") | |
return | |
for window in window_list: | |
window_id = window.split()[0] | |
subprocess.run(f"xdotool windowactivate {window_id}", shell=True) | |
time.sleep(0.2) | |
max_tabs_to_check = 10 | |
for _ in range(max_tabs_to_check): | |
window_title = get_active_window_title() | |
if window_title and meet_title_fragment in window_title: | |
print(f"Google Meet tab found in window {window_id} with title: {window_title}") | |
subprocess.run("xdotool key Ctrl+d", shell=True) | |
return | |
subprocess.run("xdotool key Ctrl+Tab", shell=True) | |
time.sleep(0.2) | |
if __name__ == "__main__": | |
focus_or_open_chrome_meet() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment