-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gnome: fix Home Manager activation (#860)
This suffers from the same issues as the KDE activation: - The program is not available in $PATH, but should not be installed for all users. - The program only works when GNOME Shell is running. Therefore, we use a very similar solution. Link: #860 Reviewed-by: NAHO <[email protected]>
- Loading branch information
Showing
2 changed files
with
53 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,36 @@ let | |
fontSize = toString config.stylix.fonts.sizes.applications; | ||
documentFontSize = toString (config.stylix.fonts.sizes.applications - 1); | ||
|
||
activator = pkgs.writeShellApplication { | ||
name = "stylix-activate-gnome"; | ||
text = '' | ||
get_exe() { | ||
for directory in /run/current-system/sw/bin /usr/bin /bin; do | ||
if [[ -f "$directory/$1" ]]; then | ||
printf '%s\n' "$directory/$1" | ||
return 0 | ||
fi | ||
done | ||
echo "Skipping '$1': command not found" | ||
return 1 | ||
} | ||
if gnome_extensions="$(get_exe gnome-extensions)"; then | ||
extension='[email protected]' | ||
case "$1" in | ||
reload) | ||
"$gnome_extensions" disable "$extension" | ||
"$gnome_extensions" enable "$extension" | ||
;; | ||
enable) | ||
"$gnome_extensions" enable "$extension" | ||
;; | ||
esac | ||
fi | ||
''; | ||
}; | ||
|
||
in | ||
{ | ||
options.stylix.targets.gnome.enable = | ||
|
@@ -55,19 +85,27 @@ in | |
"org/gnome/shell/extensions/user-theme".name = "Stylix"; | ||
}; | ||
|
||
xdg.dataFile."themes/Stylix/gnome-shell/gnome-shell.css" = { | ||
source = | ||
let | ||
theme = pkgs.callPackage ./theme.nix { | ||
inherit (config.lib.stylix) colors templates; | ||
}; | ||
in | ||
"${theme}/share/gnome-shell/gnome-shell.css"; | ||
onChange = '' | ||
if [[ -x "$(command -v gnome-extensions)" ]]; then | ||
gnome-extensions disable [email protected] | ||
gnome-extensions enable [email protected] | ||
fi | ||
xdg = { | ||
dataFile."themes/Stylix/gnome-shell/gnome-shell.css" = { | ||
source = | ||
let | ||
theme = pkgs.callPackage ./theme.nix { | ||
inherit (config.lib.stylix) colors templates; | ||
}; | ||
in | ||
"${theme}/share/gnome-shell/gnome-shell.css"; | ||
|
||
# Reload the extension so the new theme is applied immediately. | ||
# (The extension doesn't watch the file for changes.) | ||
onChange = "${lib.getExe activator} reload"; | ||
}; | ||
|
||
# Enable the extension after logging in. | ||
configFile."autostart/stylix-activate-gnome.desktop".text = '' | ||
[Desktop Entry] | ||
Type=Application | ||
Exec=${lib.getExe activator} enable | ||
Name=Stylix: enable User Themes extension for GNOME Shell | ||
''; | ||
}; | ||
}; | ||
|
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