swaync: add button to toggle feedbackd

this is just a proof of concept: will toggle GPS later
This commit is contained in:
2023-09-15 16:09:28 +00:00
parent c73246d7c6
commit fdc37c9f53

View File

@@ -38,6 +38,20 @@ let
''; '';
}; };
fbcli = "${fbcli-wrapper}/bin/swaync-fbcli"; fbcli = "${fbcli-wrapper}/bin/swaync-fbcli";
systemctl-toggle = pkgs.writeShellApplication {
name = "systemctl-toggle";
runtimeInputs = [
pkgs.systemd
];
text = ''
if systemctl is-active "$@"; then
systemctl stop "$@"
else
systemctl start "$@"
fi
'';
};
in in
{ {
sane.programs.swaynotificationcenter = { sane.programs.swaynotificationcenter = {
@@ -56,13 +70,35 @@ in
default = {}; default = {};
}; };
# prevent dbus from automatically activating swaync so i can manage it as a systemd service instead # prevent dbus from automatically activating swaync so i can manage it as a systemd service instead
package = pkgs.rmDbusServices pkgs.swaynotificationcenter; package = pkgs.rmDbusServices (pkgs.swaynotificationcenter.overrideAttrs (upstream: {
# allow toggle buttons:
patches = (upstream.patches or []) ++ [
(pkgs.fetchpatch {
url = "https://github.com/ErikReider/SwayNotificationCenter/pull/304.patch";
name = "Add toggle button";
hash = "sha256-bove2EXc5FZ5nN1X1FYOn3czCgHG03ibIAupJNoctiM=";
})
(pkgs.fetchpatch {
url = "https://git.uninsane.org/colin/SwayNotificationCenter/commit/f5d9405e040fc42ea98dc4d37202c85728d0d4fd.patch";
name = "toggleButton: change active field to be a command";
hash = "sha256-Y8fiZbAP9yGOVU3rOkZKO8TnPPlrGpINWYGaqeeNzF0=";
})
];
}));
suggestedPrograms = [ "feedbackd" ]; suggestedPrograms = [ "feedbackd" ];
fs.".config/swaync/style.css".symlink.text = '' fs.".config/swaync/style.css".symlink.text = ''
/* avoid black-on-black text that the default style ships */ /* avoid black-on-black text that the default style ships */
window { window {
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
} }
button {
color: rgb(128, 128, 128);
}
button.active {
color: rgb(255, 255, 255);
background-color: rgb(0, 110, 190);
}
''; '';
fs.".config/swaync/config.json".symlink.text = builtins.toJSON { fs.".config/swaync/config.json".symlink.text = builtins.toJSON {
"$schema" = "/etc/xdg/swaync/configSchema.json"; "$schema" = "/etc/xdg/swaync/configSchema.json";
@@ -136,6 +172,7 @@ in
"title" "title"
"dnd" "dnd"
"inhibitors" "inhibitors"
"buttons-grid"
"backlight" "backlight"
"volume" "volume"
"mpris" "mpris"
@@ -146,6 +183,16 @@ in
label = "󰃝 "; label = "󰃝 ";
device = cfg.config.backlight; device = cfg.config.backlight;
}; };
buttons-grid = {
actions = [
{
type = "toggle";
label = "feedbackd";
command = "${systemctl-toggle}/bin/systemctl-toggle --user feedbackd";
active = "${pkgs.systemd}/bin/systemctl is-active --user feedbackd.service";
}
];
};
dnd = { dnd = {
text = "Do Not Disturb"; text = "Do Not Disturb";
}; };