Created
May 25, 2023 06:24
-
-
Save etherealxx/69d37cef98804592a990ab4e90700e92 to your computer and use it in GitHub Desktop.
resize spotify x window
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 | |
def get_window_ids(): | |
cmd = "xwininfo -root -tree | grep spotify" | |
output = subprocess.check_output(cmd, shell=True).decode("utf-8") | |
lines = output.strip().split("\n") | |
window_ids = [] | |
for line in lines: | |
window_info = line.split('"') | |
if len(window_info) >= 2: | |
window_id = window_info[0].strip() | |
window_ids.append(window_id) | |
return window_ids[-1] | |
def change_window_size(window_id, width, height): | |
cmd = f"wmctrl -i -r {window_id} -e 0,0,0,{width},{height} && wmctrl -i -a {window_id}" | |
subprocess.call(cmd, shell=True) | |
spotify_window_id = get_window_ids() | |
if spotify_window_id: | |
print(f"Spotify windows id is {spotify_window_id}") | |
change_window_size(spotify_window_id, 800, 600) | |
print("Window size changed successfully!") | |
else: | |
print("Spotify window not found.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment