-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove raycast and use workaround to add apps to spotlight
- Loading branch information
Showing
4 changed files
with
98 additions
and
9 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Why: Applications installed by home-manager don't show up in spotlight. This | ||
# module works around the issue. Can be removed if this is ever included | ||
# in home-manager. | ||
# Issue: https://github.com/nix-community/home-manager/issues/1341 | ||
{ | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: { | ||
home.activation = { | ||
trampolineApps = let | ||
apps = pkgs.buildEnv { | ||
name = "home-manager-applications"; | ||
paths = config.home.packages; | ||
pathsToLink = "/Applications"; | ||
}; | ||
in | ||
lib.hm.dag.entryAfter ["writeBoundary"] '' | ||
toDir="$HOME/Applications/HMApps" | ||
fromDir="${apps}/Applications" | ||
rm -rf "$toDir" | ||
mkdir "$toDir" | ||
( | ||
cd "$fromDir" | ||
for app in *.app; do | ||
/usr/bin/osacompile -o "$toDir/$app" -e "do shell script \"open '$fromDir/$app'\"" | ||
icon="$(/usr/bin/plutil -extract CFBundleIconFile raw "$fromDir/$app/Contents/Info.plist")" | ||
if [[ $icon != *".icns" ]]; then | ||
icon="$icon.icns" | ||
fi | ||
mkdir -p "$toDir/$app/Contents/Resources" | ||
cp -f "$fromDir/$app/Contents/Resources/$icon" "$toDir/$app/Contents/Resources/applet.icns" | ||
done | ||
) | ||
''; | ||
}; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
# dest="/Users/${username}/Applications/Home Manager Trampolines/" | ||
# src="${apps}/Applications/" | ||
# rm -rf "$dest" && mkdir -p "$dest" | ||
# export dest | ||
|
||
# for file do | ||
# # escape the filename because space separated filenames suck | ||
# filename="''${file@Q}" | ||
# appname="$(basename "$file")" | ||
# out="$dest/$appname" | ||
|
||
# # This is basically going to be the script body | ||
# open_cmd=( | ||
# "open" | ||
# \"$file\" | ||
# ) | ||
# open_cmd="''${open_cmd[@]}" | ||
|
||
# # generate a wrapper app visible to spotlight | ||
# wrapper=( | ||
# "do" | ||
# "shell" | ||
# "script" | ||
# "$open_cmd" | ||
# ) | ||
# wrapper="''${wrapper[@]}" | ||
# /usr/bin/osacompile -o "$out" -e "$wrapper" 2>/dev/null | ||
|
||
# # time to make stuff visible in spotlight | ||
# plutil=/usr/bin/plutil | ||
# contents=/Contents | ||
# resources="$contents/Resources" | ||
# plist="$contents/Info.plist" | ||
|
||
# # splice in the icon | ||
# icon="$("$plutil" -extract CFBundleIconFile raw "$file/$plist")" | ||
# icon="''${icon%.icns}.icns" | ||
# icon_src="$file/$resources/$icon" | ||
# mkdir -p "$out/$resources" && cp "$icon_src" "$_/applet.icns" | ||
# done | ||
|
||
function thing() { | ||
files=("$@") | ||
|
||
for file in "${files[@]}"; do | ||
|
||
/usr/bin/osacompile -o "$toDir/$app" -e 'do shell script "open \"$fromDir/$app\""' | ||
icon="$(/usr/bin/plutil -extract CFBundleIconFile raw "$fromDir/$app/Contents/Info.plist")" | ||
mkdir -p "$toDir/$app/Contents/Resources" | ||
cp -f "$fromDir/$app/Contents/Resources/$icon" "$toDir/$app/Contents/Resources/applet.icns" | ||
|
||
done | ||
} | ||
|
||
export -f thing | ||
find . -exec sh -c 'thing "$@"' sh {} + |