-
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.
- Loading branch information
Showing
3 changed files
with
72 additions
and
39 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 |
---|---|---|
@@ -1,30 +1,48 @@ | ||
{ | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: { | ||
home.activation.setupDiscordSettings = lib.hm.dag.entryAfter ["writeBoundary"] '' | ||
verboseEcho "Setting up Discord config..." | ||
verboseEcho "Config path: ${config.xdg.configHome}/discord" | ||
}: let | ||
setup-discord-settings = pkgs.writeShellScriptBin "setup-discord-settings" '' | ||
DISCORD_CONFIG="${config.xdg.configHome}/discord" | ||
SETTINGS_FILE="$DISCORD_CONFIG/settings.json" | ||
run mkdir -p "$DISCORD_CONFIG" | ||
echo "Setting up Discord config..." | ||
echo "Config path: $DISCORD_CONFIG" | ||
# Create directory if it doesn't exist | ||
mkdir -p "$DISCORD_CONFIG" | ||
if [ ! -f "$SETTINGS_FILE" ] || [ ! -s "$SETTINGS_FILE" ]; then | ||
verboseEcho "Creating new Discord settings file..." | ||
run echo '{"SKIP_HOST_UPDATE": true}' > "$SETTINGS_FILE" | ||
verboseEcho "$(cat "$SETTINGS_FILE" || echo "<empty file>")" | ||
echo "Creating new Discord settings file..." | ||
echo '{"SKIP_HOST_UPDATE": true}' > "$SETTINGS_FILE" | ||
echo "Created with content: $(cat "$SETTINGS_FILE" || echo "<empty file>")" | ||
else | ||
verboseEcho "Updating Discord settings..." | ||
verboseEcho "Current content:" | ||
verboseEcho "$(cat "$SETTINGS_FILE" || echo "<empty file>")" | ||
echo "Updating Discord settings..." | ||
echo "Current content: $(cat "$SETTINGS_FILE" || echo "<empty file>")" | ||
${pkgs.jq}/bin/jq '. + {"SKIP_HOST_UPDATE": true}' "$SETTINGS_FILE" > "$SETTINGS_FILE.tmp" | ||
run mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE" | ||
verboseEcho "New content:" | ||
verboseEcho "$(cat "$SETTINGS_FILE" || echo "<empty file>")" | ||
mv "$SETTINGS_FILE.tmp" "$SETTINGS_FILE" | ||
echo "New content: $(cat "$SETTINGS_FILE" || echo "<empty file>")" | ||
fi | ||
''; | ||
in { | ||
home.packages = [setup-discord-settings]; | ||
|
||
systemd.user.services.discord-settings = { | ||
Unit = { | ||
Description = "Setup Discord Settings"; | ||
After = ["basic.target"]; | ||
Before = ["graphical-session.target"]; | ||
}; | ||
|
||
Install = { | ||
WantedBy = ["basic.target"]; | ||
}; | ||
|
||
Service = { | ||
Type = "oneshot"; | ||
RemainAfterExit = true; | ||
ExecStart = "${setup-discord-settings}/bin/setup-discord-settings"; | ||
}; | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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