daily configuration optimization
Fix - airplay: systemd wantedBy target - fcitx5: remove redundant systemd service Remove - move scripts into configuration Style - ghostty: add more transparency to background Add - zellij
This commit is contained in:
parent
44c152fdc9
commit
9c9acc3494
24 changed files with 941 additions and 856 deletions
46
helper/default.nix
Normal file
46
helper/default.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
}:
|
||||
let
|
||||
inherit (pkgs) writeShellScript;
|
||||
inherit (lib) replaceString;
|
||||
inherit (builtins) toJSON mapAttrs;
|
||||
in
|
||||
{
|
||||
mkToggleScript =
|
||||
{
|
||||
service,
|
||||
start,
|
||||
stop,
|
||||
icon ? "",
|
||||
extra ? { },
|
||||
}:
|
||||
let
|
||||
extraJson = replaceString "\"" "\\\"" (toJSON extra);
|
||||
in
|
||||
writeShellScript "${service}-toggle.sh" ''
|
||||
SERVICE_NAME=${service}
|
||||
EXTRA_JSON="${extraJson}"
|
||||
|
||||
case $1 in toggle)
|
||||
if systemctl --user is-active --quiet "$SERVICE_NAME"; then
|
||||
systemctl --user stop "$SERVICE_NAME"
|
||||
notify-send "${icon} ''\${SERVICE_NAME^}" "stopping"
|
||||
else
|
||||
systemctl --user start "$SERVICE_NAME"
|
||||
notify-send "${icon} ''\${SERVICE_NAME^}" "starting"
|
||||
fi
|
||||
esac
|
||||
|
||||
if systemctl --user is-active --quiet "$SERVICE_NAME"; then
|
||||
json1=$(jq -nc --arg text "${icon} ''\${SERVICE_NAME^} starting" --arg class "${start}" \
|
||||
'{text: $text, tooltip: $text, class: $class, alt: $class}')
|
||||
else
|
||||
json1=$(jq -nc --arg text "${icon} ''\${SERVICE_NAME^} stopped" --arg class "${stop}" \
|
||||
'{text: $text, tooltip: $text, class: $class, alt: $class}')
|
||||
fi
|
||||
|
||||
jq -nc --argjson a "$json1" --argjson b "$EXTRA_JSON" '$a + $b'
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue