diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f52bb6..b051c868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Config *global setting* `split_type` is now categorized as a *space setting* instead [#2479](https://github.com/koekeishiya/yabai/issues/2479) - Additional options `x-axis` and `y-axis` can now be used with `config auto_balance` command [#190](https://github.com/koekeishiya/yabai/issues/190) - Minor adjustment to screen-padding and window-gap [#2502](https://github.com/koekeishiya/yabai/issues/2502) +- Replace seticon script with AppleScript implementation instead of Python ## [7.1.5] - 2024-11-01 ### Changed diff --git a/makefile b/makefile index ba47be3a..5108a633 100644 --- a/makefile +++ b/makefile @@ -39,7 +39,7 @@ man: asciidoctor -b manpage $(DOC_PATH)/yabai.asciidoc -o $(DOC_PATH)/yabai.1 icon: - python3 $(SCRIPT_PATH)/seticon.py $(ASSET_PATH)/icon/2x/icon-512px@2x.png $(BUILD_PATH)/yabai + osascript $(SCRIPT_PATH)/seticon.scpt $(ASSET_PATH)/icon/2x/icon-512px@2x.png $(BUILD_PATH)/yabai publish: sed -i '' "60s/^VERSION=.*/VERSION=\"$(shell $(BUILD_PATH)/yabai --version | cut -d "v" -f 2)\"/" $(SCRIPT_PATH)/install.sh diff --git a/scripts/seticon.py b/scripts/seticon.py deleted file mode 100755 index 6cbff43b..00000000 --- a/scripts/seticon.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python - -import Cocoa -import sys - -image = Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1]); -binary = sys.argv[2]; -options = 0; - -result = Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(image, binary, options); -if result == 0: print("could not set icon for file.."); diff --git a/scripts/seticon.scpt b/scripts/seticon.scpt new file mode 100755 index 00000000..2bb12d4a --- /dev/null +++ b/scripts/seticon.scpt @@ -0,0 +1,27 @@ +#!/usr/bin/env osascript + +use framework "AppKit" + +-------------------------------------------------------------------------------- +# PROPERTY DECLARATIONS: +property this : a reference to current application +property NSWorkspace : a reference to NSWorkspace of this +property NSImage : a reference to NSImage of this + +-------------------------------------------------------------------------------- +# IMPLEMENTATION: +on run argv + set icon to item 1 of argv + set target to item 2 of argv + + setIcon to icon for target +end run +-------------------------------------------------------------------------------- +# HANDLERS: +to setIcon to iconPath for filePath + set sharedWorkspace to NSWorkspace's sharedWorkspace() + set newImage to NSImage's alloc() + set icon to newImage's initWithContentsOfFile:iconPath + + set success to sharedWorkspace's setIcon:icon forFile:filePath options:0 +end setIcon