commit 7c261696367e639d615553ffb643350858289cdb
parent a2194c1a5b2b7c9ab47f127d9807881a0b4389d7
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 17 Jun 2022 16:42:47 +0200
parent a2194c1a5b2b7c9ab47f127d9807881a0b4389d7
Author: Leah (ctucx) <leah@ctu.cx>
Date: Fri, 17 Jun 2022 16:42:47 +0200
darwin/appIcons: patch Icon for coconutBattery, LibreOffice, Telegram
2 files changed, 101 insertions(+), 35 deletions(-)
A
|
97
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/configurations/darwin/appIcons.nix b/configurations/darwin/appIcons.nix @@ -0,0 +1,97 @@ +{ pkgs, lib, ... }: + +let + setIcon = pkgs.writeScript "setIcon.osascript" '' + #!/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 + ''; + + TelegramAppIcon = pkgs.fetchurl { url = "https://media.macosicons.com/parse/files/macOSicons/8f18e7156bb932429ec99016d765f95a_Telegram.icns"; sha256 = "sha256-lPsU5ih/ubg1NJHsrOr1SqgQQ4WN2BKacd5fp26gZa4"; }; + coconutBatteryAppIcon = pkgs.fetchurl { url = "https://media.macosicons.com/parse/files/macOSicons/740fe98d7cb4e087ef45459d60a2b745_coconutBattery.icns"; sha256 = "sha256-Yxg0LBf+7Rdx1Fvwib3I3UnoVC0bwjb7r9r8Cj3I4Pc"; }; + +in { + + system.activationScripts.postActivation.text = '' + # + # Update app-icons + # + ICONS_CHANGED=0; + + # Telegram + if [ ! -e $'/Applications/Telegram.app/Icon\r' ]; then + echo -n "Update Telegram.app Icon: " + ${setIcon} ${TelegramAppIcon} /Applications/Telegram.app; + fi + + # coconutBattery + if [ ! -e $'/Applications/coconutBattery.app/Icon\r' ]; then + echo -n "Update coconutBattery.app Icon: " + ${setIcon} ${coconutBatteryAppIcon} /Applications/coconutBattery.app; + fi + + # LibreOffice + if [ -e '/Aplications/LibreOffice.app' ]; then + ICON_SHA256="$(shasum -a 256 /Applications/LibreOffice.app/Contents/Resources/main.icns | awk '{ print $1 }')"; + + if [ "$ICON_SHA256" != '83bf2c0f0dfaea592224a7d2ea981e4e3c6ba57da64913a43535e62da059c357' ]; then + curl -o /Applications/LibreOffice.app/Contents/Resources/main.icns 'https://media.macosicons.com/parse/files/macOSicons/ce3097d5c5ce2322c7a868ed29f61cd8_Libre_Office.icns'; + touch '/Applications/LibreOffice.app'; + ICONS_CHANGED=1; + fi + fi + + # Firefox + if [ -e '/Applications/Firefox.app' ]; then + ICON_SHA256="$(shasum -a 256 /Applications/Firefox.app/Contents/Resources/firefox.icns | awk '{ print $1 }')"; + + if [ "$ICON_SHA256" != 'd1753c860526f2806ce53ac0a47a84d727d80fcaf30b9e4dc42d9bfafdde83be' ]; then + curl -o /Applications/Firefox.app/Contents/Resources/firefox.icns 'https://media.macosicons.com/parse/files/macOSicons/3e2e434eb31e1d096e4fe6d87857ad0b_Firefox.icns'; + touch '/Applications/Firefox.app'; + ICONS_CHANGED=1; + fi + fi + + # Thunderbird + if [ -e '/Applications/Thunderbird.app' ]; then + ICON_SHA256="$(shasum -a 256 /Applications/Thunderbird.app/Contents/Resources/thunderbird.icns | awk '{ print $1 }')"; + + if [ "$ICON_SHA256" != 'de65b6d8b7d043eac03248b92e09ef946ddf6b60adf0479f60fe2b42a23d1e82' ]; then + curl -o /Applications/Thunderbird.app/Contents/Resources/thunderbird.icns 'https://media.macosicons.com/parse/files/macOSicons/d05f6c9df12594a119f87ba6b30d663f_Thunderbird.icns'; + touch '/Applications/Thunderbird.app'; + ICONS_CHANGED=1; + fi + fi + + # When an icon was changed, delete the icon-cache and restart Dock.app + if [ $ICONS_CHANGED -ne 0 ]; then + rm /var/folders/*/*/*/com.apple.dock.iconcache; + killall Dock; + fi + ''; + +}
diff --git a/configurations/darwin/homebrew.nix b/configurations/darwin/homebrew.nix @@ -1,6 +1,10 @@ { ... }: { + imports = [ + ./appIcons.nix + ]; + homebrew = { enable = true; cleanup = "zap"; @@ -45,41 +49,6 @@ rm $MACOS_JAVAVM; fi fi - - # - # Update app-icons - # - - - ICONS_CHANGED=0; - - #Firefox - if [ -e '/Applications/Firefox.app' ]; then - ICON_SHA256="$(shasum -a 256 /Applications/Firefox.app/Contents/Resources/firefox.icns | awk '{ print $1 }')"; - - if [ "$ICON_SHA256" != 'd1753c860526f2806ce53ac0a47a84d727d80fcaf30b9e4dc42d9bfafdde83be' ]; then - curl -o /Applications/Firefox.app/Contents/Resources/firefox.icns 'https://media.macosicons.com/parse/files/macOSicons/3e2e434eb31e1d096e4fe6d87857ad0b_Firefox.icns'; - touch '/Applications/Firefox.app'; - ICONS_CHANGED=1; - fi - fi - - #Thunderbird - if [ -e '/Applications/Thunderbird.app' ]; then - ICON_SHA256="$(shasum -a 256 /Applications/Thunderbird.app/Contents/Resources/thunderbird.icns | awk '{ print $1 }')"; - - if [ "$ICON_SHA256" != 'de65b6d8b7d043eac03248b92e09ef946ddf6b60adf0479f60fe2b42a23d1e82' ]; then - curl -o /Applications/Thunderbird.app/Contents/Resources/thunderbird.icns 'https://media.macosicons.com/parse/files/macOSicons/d05f6c9df12594a119f87ba6b30d663f_Thunderbird.icns'; - touch '/Applications/Thunderbird.app'; - ICONS_CHANGED=1; - fi - fi - - # When an icon was changed, delete the icon-cache and restart Dock.app - if [ $ICONS_CHANGED -ne 0 ]; then - rm /var/folders/*/*/*/com.apple.dock.iconcache; - killall Dock; - fi ''; }