1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: replace deadd with wired-notify ❤️ muchhh better

This commit is contained in:
oddlama 2023-10-02 02:08:41 +02:00
parent 59bee10697
commit 070a92468e
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
11 changed files with 268 additions and 527 deletions

85
flake.lock generated
View file

@ -65,6 +65,28 @@
"type": "github"
}
},
"alejandra": {
"inputs": {
"flakeCompat": "flakeCompat",
"nixpkgs": [
"wired-notify",
"nixpkgs"
]
},
"locked": {
"lastModified": 1652974241,
"narHash": "sha256-0AolxQtKj3Oek0WSbODDpPVO5Ih8PXHOA3qXEKPB4dQ=",
"owner": "kamadorueda",
"repo": "alejandra",
"rev": "0be1462419fc73270a5dc0f84f8092603890b029",
"type": "github"
},
"original": {
"owner": "kamadorueda",
"repo": "alejandra",
"type": "github"
}
},
"base16": {
"inputs": {
"fromYaml": "fromYaml"
@ -426,6 +448,22 @@
"type": "github"
}
},
"flakeCompat": {
"flake": false,
"locked": {
"lastModified": 1648199409,
"narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"fromYaml": {
"flake": false,
"locked": {
@ -836,16 +874,17 @@
]
},
"locked": {
"lastModified": 1695643200,
"narHash": "sha256-49SPrO9fWeIoSXS5pFFFhcC4kyfQik5B2J+GSuMopjE=",
"lastModified": 1696161600,
"narHash": "sha256-J/Xet8H6vI7iGdL1CdD/gdVRJmD7l7gTxEjpdu6g6HE=",
"owner": "symphorien",
"repo": "nixseparatedebuginfod",
"rev": "318ada174f6e6510a50abb69b7765a28c8009b1a",
"rev": "466110a37e11a33a3551b44d9da5e323a8924cfa",
"type": "github"
},
"original": {
"owner": "symphorien",
"repo": "nixseparatedebuginfod",
"rev": "466110a37e11a33a3551b44d9da5e323a8924cfa",
"type": "github"
}
},
@ -952,7 +991,8 @@
"nixseparatedebuginfod": "nixseparatedebuginfod",
"pre-commit-hooks": "pre-commit-hooks_3",
"stylix": "stylix",
"templates": "templates"
"templates": "templates",
"wired-notify": "wired-notify"
}
},
"rust-overlay": {
@ -1133,6 +1173,43 @@
"repo": "treefmt-nix",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1652776076,
"narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"wired-notify": {
"inputs": {
"alejandra": "alejandra",
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1683104317,
"narHash": "sha256-TfPrY+sqCKfRiBhO3oz0t/i9IGcTuGGQMKhkD+LpMys=",
"owner": "Toqozz",
"repo": "wired-notify",
"rev": "73bb26863ed3272e0d524424685bd53a70db25e4",
"type": "github"
},
"original": {
"owner": "Toqozz",
"repo": "wired-notify",
"type": "github"
}
}
},
"root": "root",

View file

@ -92,6 +92,11 @@
};
templates.url = "github:NixOS/templates";
wired-notify = {
url = "github:Toqozz/wired-notify";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {

View file

@ -10,6 +10,7 @@
verbose = true;
sharedModules = [
inputs.nix-index-database.hmModules.nix-index
inputs.wired-notify.homeManagerModules.default
{
home.stateVersion = config.system.stateVersion;
}

View file

@ -50,5 +50,6 @@
nixpkgs.overlays = [
inputs.microvm.overlay
inputs.nixpkgs-wayland.overlay
inputs.wired-notify.overlays.default
];
}

View file

@ -1,73 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
mkOption
mkEnableOption
mkPackageOption
literalExpression
mkIf
types
;
settingsFormat = pkgs.formats.yaml {};
cfg = config.services.deadd-notification-center;
in {
options.services.deadd-notification-center = {
enable = mkEnableOption "deadd notification center";
package = mkPackageOption pkgs "deadd-notification-center" {};
settings = mkOption {
default = {};
type = types.submodule {
freeformType = settingsFormat.type;
};
description = ''
Settings for the notification center.
Refer to https://github.com/phuhl/linux_notification_center#configuration for available options.
'';
example = literalExpression ''
{
notification-center = {
marginTop = 30;
width = 500;
};
}
'';
};
style = mkOption {
type = types.lines;
description = "CSS styling for notifications.";
};
};
config = mkIf cfg.enable {
xdg.configFile."deadd/deadd.yml".source = settingsFormat.generate "deadd.yml" cfg.settings;
xdg.configFile."deadd/deadd.css".text = cfg.style;
systemd.user.services.deadd-notification-center = {
Install.WantedBy = ["graphical-session.target"];
Unit = {
Description = "Deadd Notification Center";
After = ["graphical-session-pre.target"];
PartOf = ["graphical-session.target"];
X-Restart-Triggers = [
config.xdg.configFile."deadd/deadd.yml".source
config.xdg.configFile."deadd/deadd.css".source
];
};
Service = {
Type = "dbus";
BusName = "org.freedesktop.Notifications";
ExecStart = "${cfg.package}/bin/deadd-notification-center";
Restart = "always";
RestartSec = "1sec";
};
};
};
}

View file

@ -1,6 +1,5 @@
{...}: {
imports = [
./deadd-notification-center.nix
./uid.nix
./secrets.nix
./neovim.nix

View file

@ -1,249 +0,0 @@
{
services.deadd-notification-center = {
enable = true;
settings = {
### Margins for notification-center/notifications
margin-top = 0;
margin-right = 0;
### Margins for notification-center
margin-bottom = 0;
### Width of the notification center/notifications in pixels.
width = 500;
### Command to run at startup. This can be used to setup
### button states.
# startup-command = deadd-notification-center-startup;
### Monitor on which the notification center/notifications will be
### printed. If "follow-mouse" is set true, this does nothing.
monitor = 0;
### If true, the notification center/notifications will open on the
### screen, on which the mouse is. Overrides the "monitor" setting.
follow-mouse = false;
notification-center = {
### Margin at the top/right/bottom of the notification center in
### pixels. This can be used to avoid overlap between the notification
### center and bars such as polybar or i3blocks.
# margin-top = 0;
# margin-right = 0;
# margin-bottom = 0;
### Width of the notification center in pixels.
# width = 500;
### Monitor on which the notification center will be printed. If
### "follow-mouse" is set true, this does nothing.
# monitor = 0;
### If true, the notification center will open on the screen, on which
### the mouse is. Overrides the "monitor" setting.
# follow-mouse = false;
### Notification center closes when the mouse leaves it
hide-on-mouse-leave = true;
### If newFirst is set to true, newest notifications appear on the top
### of the notification center. Else, notifications stack, from top to
### bottom.
new-first = true;
### If true, the transient field in notifications will be ignored,
### thus the notification will be persisted in the notification
### center anyways
ignore-transient = false;
### Custom buttons in notification center
#buttons:
### Numbers of buttons that can be drawn on a row of the notification
### center.
# buttons-per-row = 5;
### Height of buttons in the notification center (in pixels).
# buttons-height = 60;
### Horizontal and vertical margin between each button in the
### notification center (in pixels).
# buttons-margin = 2;
### Button actions and labels. For each button you must specify a
### label and a command.
#actions:
# - label: VPN
# command: "sudo vpnToggle"
# - label: Bluetooth
# command: bluetoothToggle
# - label: Wifi
# command: wifiToggle
# - label: Screensaver
# command: screensaverToggle
# - label: Keyboard
# command: keyboardToggle
};
notification = {
use-markup = true;
parse-html-entities = true;
dbus.send-noti-closed = true;
app-icon = {
guess-icon-from-name = true;
icon-size = 20;
};
image = {
size = 100;
### The margin around the top, bottom, left, and right of
### notification images.
margin-top = 15;
margin-bottom = 15;
margin-left = 15;
margin-right = 0;
};
### Apply modifications to certain notifications:
### Each modification rule needs a "match" and either a "modify" or
### a "script" entry.
#modifications:
### Match:
### Matches the notifications against these rules. If all of the
### values (of one modification rule) match, the "modify"/"script"
### part is applied.
# - match:
### Possible match criteria:
# title: "Notification title"
# body: "Notification body"
# time: "12:44"
# app-name: "App name"
# urgency: "low" # "low", "normal" or "critical"
# modify:
### Possible modifications
# title: "abc"
# body: "abc"
# app-name: "abc"
# app-icon: "file:///abc.png"
### The timeout has three special values:
### timeout: 0 -> don't time out at all
### timeout: -1 -> use default timeout
### timeout: 1 -> don't show as pop-up
### timeout: >1 -> milliseconds until timeout
# timeout: 1
# margin-right: 10
# margin-top: 10
# image: "file:///abc.png"
# image-size: 10
# transient: true
# send-noti-closed: false
### Remove action buttons from notifications
# remove-actions: true
### Set the action-icons hint to true, action labels will then
### be intergreted as GTK icon names
# action-icons: true
### List of actions, where the even elements (0, 2, ...) are the
### action name and the odd elements are the label
# actions:
# - previous
# - media-skip-backward
# - play
# - media-playback-start
# - next
# - media-skip-forward
### Action commands, where the keys (e.g. "play") is the action
### name and the value is a program call that should be executed
### on action. Prevents sending of the action to the application.
# action-commands:
# play: playerctl play-pause
# previous: playerctl previous
# next: playerctl next
### Add a class-name to the notification container, that can be
### used for specific styling of notifications using the
### deadd.css file
# class-name: "abc"
# - match:
# app-name: "Chromium"
### Instead of modifying a notification directly, a script can be
### run, which will receive the notification as JSON on STDIN. It
### is expected to return JSON/YAML configuration that defines the
### modifications that should be applied. Minimum complete return
### value must be '{"modify": {}, "match": {}}'. Always leave the "match"
### object empty (technical reasons, i.e. I am lazy).
# script: "linux-notification-center-parse-chromium"
#- match:
# app-name: "Spotify"
# modify:
# image-size: 80
# timeout: 1
# send-noti-closed: true
# class-name: "Spotify"
# action-icons: true
# actions:
# - previous
# - media-skip-backward
# - play
# - media-playback-start
# - next
# - media-skip-forward
# action-commands:
# play: playerctl play-pause
# previous: playerctl previous
# next: playerctl next
# - match:
# title: Bildschirmhelligkeit
# modify:
# image-size: 60
popup = {
### Default timeout used for notifications in milli-seconds. This can
### be overwritten with the "-t" option (or "--expire-time") of the
### notify-send command.
default-timeout = 10000;
### Margin above/right/between notifications (in pixels). This can
### be used to avoid overlap between notifications and a bar such as
### polybar or i3blocks.
margin-top = 50;
margin-right = 50;
margin-between = 20;
### Defines after how many lines of text the body will be truncated.
### Use 0 if you want to disable truncation.
max-lines-in-body = 3;
### Determines whether the GTK widget that displays the notification body
### in the notification popup will be hidden when empty. This is especially
### useful for transient notifications that display a progress bar.
# hide-body-if-empty = false;
### Monitor on which the notifications will be
### printed. If "follow-mouse" is set true, this does nothing.
# monitor = 0;
### If true, the notifications will open on the
### screen, on which the mouse is. Overrides the "monitor" setting.
# follow-mouse = false;
click-behavior = {
### The mouse button for dismissing a popup. Must be either "mouse1",
### "mouse2", "mouse3", "mouse4", or "mouse5"
dismiss = "mouse1";
### The mouse button for opening a popup with the default action.
### Must be either "mouse1", "mouse2", "mouse3", "mouse4", or "mouse5"
default-action = "mouse3";
#notification.dbus.send-noti-closed = false;
};
};
};
};
style = builtins.readFile ./deadd.css;
};
}

View file

@ -1,199 +0,0 @@
/* Notification center */
.deadd-noti-center {
color: #ffffff;
}
.blurredBG, #main_window, .blurredBG.low, .blurredBG.normal {
background: #000000;
}
/* Notifications */
.notificationInCenter, .notification.container {
background: #333;
border-radius: .825em;
padding: .75em;
margin-left: .25em;
margin-right: .25em;
margin-top: .25em;
margin-bottom: -.75em;
}
.blurredBG.notification {
background: #333;
}
.notificationInCenter > *, .notification > * {
margin: 0em;
}
.notification.appname, .in-center.appname {
color: #aaa;
font-weight: normal;
font-size: 1.125rem;
}
.notification.body, .in-center.body {
font-size: 1.5rem;
margin-bottom: .25em;
margin-top: .25em;
margin-left: 0em;
}
.notification.title, .in-center.title {
font-weight: bold;
font-size: 1.75rem;
}
.notification.image, .in-center.image {
}
.notification.icon, .in-center.icon {
}
.notification.actionbutton, .in-center.actionbutton {
}
.notification.scale, .in-center.scale {
margin-top: .25em;
margin-bottom: .25em;
margin-left: -.75em;
margin-right: -.75em;
}
.notification.scale slider, .in-center.scale slider {
margin: -.375em;
min-width: 1.375em;
min-height: 1.375em;
}
.notification.scale trough, .in-center.scale trough {
background-color: #111;
color: #111;
border-color: transparent;
border-radius: 1em;
}
.notification.scale trough highlight, .in-center.scale trough highlight {
background-color: #f00;
color: #f00;
border-color: transparent;
border-radius: 1em;
}
.notification.appname {
}
.notification.body {
}
.notification.title {
}
.notification.image {
margin-left: -1em;
margin-right: 1em;
}
.notification.icon {
}
.notification.actionbutton {
}
.in-center {
}
.in-center.appname {
}
.in-center.body {
}
.in-center.title {
}
.in-center.time {
color: #777;
font-weight: bold;
font-size: 1.125rem;
font-family: normal;
}
.in-center.image {
}
.in-center.icon {
}
.in-center.button-close {
}
.in-center.actionbutton {
}
.noti-center.body {
}
.noti-center.time {
font-size: 4rem;
font-weight: normal;
margin-left: .25em;
}
.noti-center.date {
font-size: 2rem;
margin-left: .75em;
}
/* BUG: missing .noti-center class upstream */
.deadd-noti-center.delete-all {
font-size: 2rem;
}
.noti-center.userbutton {
}
/* Buttons */
button {
background: transparent;
border-radius: 3px;
border-width: 0px;
background-position: 0px 0px;
text-shadow: none;
}
button:hover {
border-radius: 3px;
background: rgba(0, 20, 20, 0.2);
border-width: 0px;
border-top: transparent;
border-color: #f00;
}
/* Custom Buttons */
.userbutton {
background: rgba(20,0,0, 0.15);
}
.userbuttonlabel {
font-size: 12px;
}
.userbutton:hover {
background: rgba(20, 0, 0, 0.2);
}
.userbuttonlabel:hover {
}
button.buttonState1 {
background: rgba(20,0,0,0.5);
}
.userbuttonlabel.buttonState1 {
}
button.buttonState1:hover {
background: rgba(20,0,0, 0.4);
}
.userbuttonlabel.buttonState1:hover {
}
button.buttonState2 {
background: rgba(255,255,255,0.3);
}
.userbuttonlabel.buttonState2 {
}
button.buttonState2:hover {
background: rgba(20,0,0, 0.3);
}
.userbuttonlabel.buttonState2:hover {
}

View file

@ -6,7 +6,7 @@
}: {
imports =
[
./deadd-notification-center.nix
./wired-notify.nix
./discord.nix
./firefox.nix
./kitty.nix

View file

@ -0,0 +1,6 @@
{
services.wired = {
enable = true;
config = ./wired.ron;
};
}

View file

@ -0,0 +1,173 @@
(
max_notifications: 10,
timeout: 4000,
poll_interval: 6, // 6ms ~= 166hz.
history_length: 60,
replacing_enabled: true,
replacing_resets_timeout: true,
min_window_width: 500,
min_window_height: 100,
debug: false,
debug_color: Color(r: 0.0, g: 1.0, b: 0.0, a: 1.0),
debug_color_alt: Color(r: 1.0, g: 0.0, b: 0.0, a: 1.0),
// https://github.com/Toqozz/wired-notify/wiki/Shortcuts
shortcuts: ShortcutsConfig (
notification_interact: 1,
notification_close: 2,
notification_action1: 3,
),
layout_blocks: [
(
name: "app_root",
parent: "",
hook: Hook(parent_anchor: MM, self_anchor: MM),
offset: Vec2(x: 0, y: 0),
render_criteria: [AppImage],
params: NotificationBlock((
monitor: 0,
border_width: 0,
border_rounding: 8,
background_color: Color(hex: "#F5F5F5"),
border_color: Color(hex: "#00000000"),
border_color_low: Color(hex: "#00000000"),
border_color_critical: Color(hex: "#FF0000"),
border_color_paused: Color(hex: "#00000000"),
gap: Vec2(x: 0.0, y: 8.0),
notification_hook: Hook(parent_anchor: BM, self_anchor: TM),
)),
),
(
name: "app_notification",
parent: "app_root",
hook: Hook(parent_anchor: TM, self_anchor: TM),
offset: Vec2(x: 0, y: 0),
params: ImageBlock((
image_type: App,
padding: Padding(left: 40, right: 40, top: 40, bottom: 8),
rounding: 4.0,
scale_width: 152,
scale_height: 152,
filter_mode: Lanczos3,
)),
),
(
name: "app_summary",
parent: "app_notification",
hook: Hook(parent_anchor: BM, self_anchor: TM),
offset: Vec2(x: 0, y: 12),
params: TextBlock((
text: "%s",
font: "Arial Bold 16",
ellipsize: End,
color: Color(hex: "#000000"),
padding: Padding(left: 0, right: 0, top: 0, bottom: 0),
dimensions: (width: (min: -1, max: 185), height: (min: 0, max: 0)),
)),
),
(
name: "app_body",
parent: "app_summary",
hook: Hook(parent_anchor: BM, self_anchor: TM),
offset: Vec2(x: 0, y: 0),
params: TextBlock((
text: "%b",
font: "Arial Bold 16",
ellipsize: End,
color: Color(hex: "#000000"),
padding: Padding(left: 0, right: 0, top: 0, bottom: 24),
dimensions: (width: (min: -1, max: 250), height: (min: 0, max: 0)),
)),
),
(
name: "app_progress",
parent: "app_notification",
hook: Hook(parent_anchor: BM, self_anchor: TM),
offset: Vec2(x: 0, y: 50),
render_criteria: [Progress],
params: ProgressBlock((
padding: Padding(left: 0, right: 0, top: 0, bottom: 32),
border_width: 2,
border_rounding: 2,
border_color: Color(hex: "#000000"),
fill_rounding: 1,
background_color: Color(hex: "#00000000"),
fill_color: Color(hex: "#000000"),
width: -1.0,
height: 30.0,
)),
),
(
name: "status_root",
parent: "",
hook: Hook(parent_anchor: TM, self_anchor: TM),
offset: Vec2(x: 0.0, y: 60),
// render_anti_criteria: [AppImage],
render_criteria: [HintImage],
params: NotificationBlock((
monitor: 0,
border_width: 0,
border_rounding: 8,
background_color: Color(hex: "#F5F5F5"),
border_color: Color(hex: "#00000000"),
border_color_low: Color(hex: "#00000000"),
border_color_critical: Color(hex: "#FF0000"),
border_color_paused: Color(hex: "#00000000"),
gap: Vec2(x: 0.0, y: 8.0),
notification_hook: Hook(parent_anchor: BM, self_anchor: TM),
)),
),
(
name: "status_notification",
parent: "status_root",
hook: Hook(parent_anchor: TL, self_anchor: TL),
offset: Vec2(x: 0, y: 0),
params: TextBlock((
text: "%s",
font: "Arial Bold 16",
ellipsize: End,
color: Color(hex: "#000000"),
padding: Padding(left: 8, right: 8, top: 8, bottom: 8),
dimensions: (width: (min: 400, max: 400), height: (min: 84, max: 0)),
)),
),
(
name: "status_body",
parent: "status_notification",
hook: Hook(parent_anchor: ML, self_anchor: TL),
offset: Vec2(x: 0, y: -24),
params: TextBlock((
text: "%b",
font: "Arial 14",
ellipsize: End,
color: Color(hex: "#000000"),
padding: Padding(left: 8, right: 8, top: 8, bottom: 8),
dimensions: (width: (min: 400, max: 400), height: (min: 0, max: 84)),
)),
),
(
name: "status_image",
parent: "status_notification",
hook: Hook(parent_anchor: TL, self_anchor: TR),
offset: Vec2(x: 0, y: 0),
params: ImageBlock((
image_type: Hint,
padding: Padding(left: 8, right: 0, top: 8, bottom: 8),
rounding: 4.0,
scale_width: 84,
scale_height: 84,
filter_mode: Lanczos3,
)),
),
],
)