From e5f4f937131b04abe21e8190ca3d043b7ed8928f Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Wed, 30 Aug 2023 12:52:00 +0200 Subject: [PATCH] changes for macos --- README_darwin.md | 4 ++++ dot_config/yabai/executable_yabairc | 17 +++++++------- scripts/executable_get_current-window.py | 28 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 scripts/executable_get_current-window.py diff --git a/README_darwin.md b/README_darwin.md index c196539..ff6fdb1 100644 --- a/README_darwin.md +++ b/README_darwin.md @@ -24,6 +24,10 @@ brew install htop brew install btop brew install asciiquarium brew install lolcat +brew install python +brew install python-tk@3.11 +brew install python-gdbm@3.11 +pip install pyobjc ~~~ ## Install Password Manager diff --git a/dot_config/yabai/executable_yabairc b/dot_config/yabai/executable_yabairc index 7342f8d..d218b8a 100644 --- a/dot_config/yabai/executable_yabairc +++ b/dot_config/yabai/executable_yabairc @@ -16,19 +16,18 @@ yabai -m space 7 --label media yabai -m space 8 --label games # window rules +yabai -m rule --add app="^WezTerm$" space=code +yabai -m rule --add app="^(Safari|Firefox)$" space=web yabai -m rule --add app="^Mail$" space=mail -yabai -m rule --add app="^Safari$" space=web -yabai -m rule --add app="^Notes$" space=notes -yabai -m rule --add app="^ida64$" space=re -yabai -m rule --add app="^Transmission$" space=media -yabai -m rule --add app="^Spotify$" space=media +yabai -m rule --add app="^Element$" space=chat yabai -m rule --add app="^Discord$" space=social grid=1:1:0:0:1:1 manage=off +yabai -m rule --add app="^(Notes|Joplin)$" space=notes +yabai -m rule --add app="^(Spotify|Fineamp|Musik)$" space=media yabai -m rule --add app="^Steam$" space=games manage=off -yabai -m rule --add app="^(Calculator|System Preferences|Archive Utility)$" manage=off -yabai -m rule --add app="^mpv$" manage=off border=off sticky=on layer=above opacity=1.0 grid=8:8:6:0:2:2 -# float system preferences -yabai -m rule --add app="^System Preferences$" manage=off +# Advanced Window rules +yabai -m rule --add app="^(Calculator|Rechner|System Preferences|Systemeinstellungen|Einstellungen|System Settings|Preferences|Aktivitätsanzeige|Archive Utility)$" manage=off +yabai -m rule --add app="^mpv$" manage=off border=off sticky=on layer=above opacity=1.0 grid=8:8:6:0:2:2 yabai -m rule --add app="^choose$" manage=off # show digital colour meter topmost and on all spaces diff --git a/scripts/executable_get_current-window.py b/scripts/executable_get_current-window.py new file mode 100644 index 0000000..41d6b5b --- /dev/null +++ b/scripts/executable_get_current-window.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# Prints list of windows in the current workspace. + +import sys +if sys.platform == "darwin": + from AppKit import NSWorkspace + from Quartz import ( + CGWindowListCopyWindowInfo, + kCGWindowListOptionOnScreenOnly, + kCGNullWindowID + ) + +if sys.platform == "darwin": + curr_app = NSWorkspace.sharedWorkspace().frontmostApplication() + curr_pid = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationProcessIdentifier'] + curr_app_name = curr_app.localizedName() + options = kCGWindowListOptionOnScreenOnly + windowList = CGWindowListCopyWindowInfo(options, kCGNullWindowID) + for window in windowList: + pid = window['kCGWindowOwnerPID'] + windowNumber = window['kCGWindowNumber'] + ownerName = window['kCGWindowOwnerName'] + geometry = window['kCGWindowBounds'] + windowTitle = window.get('kCGWindowName', u'Unknown') + if curr_pid == pid: + print("%s - %s (PID: %d, WID: %d): %s" % (ownerName, windowTitle.encode('ascii','ignore'), pid, windowNumber, geometry)) +elif sys.platform == "win32": + (active_app_name, windowTitle) = _getActiveInfo_Win32()