Skip to content

Instantly share code, notes, and snippets.

@etherealxx
Created May 25, 2023 06:24
Show Gist options
  • Save etherealxx/69d37cef98804592a990ab4e90700e92 to your computer and use it in GitHub Desktop.
Save etherealxx/69d37cef98804592a990ab4e90700e92 to your computer and use it in GitHub Desktop.
resize spotify x window
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