diff --git a/flake.lock b/flake.lock index 8fc8adf4..24918186 100644 --- a/flake.lock +++ b/flake.lock @@ -395,6 +395,22 @@ "type": "github" } }, + "master": { + "locked": { + "lastModified": 1651837199, + "narHash": "sha256-odvwvHfXQDYFtwtywISSS6EDlSN4AfcFZOon4LK9zX8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "defb285c96a521555d48e8757bc482f71e8dd12f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "master", + "repo": "nixpkgs", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": [ @@ -620,6 +636,7 @@ "digga": "digga", "home": "home", "latest": "latest_2", + "master": "master", "naersk": "naersk", "nix-dram": "nix-dram", "nixos": "nixos", diff --git a/flake.nix b/flake.nix index e9b91fc9..216d2ff0 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,7 @@ # Track channels with commits tested and built by hydra nixos.url = "github:nixos/nixpkgs/nixos-21.11"; latest.url = "github:nixos/nixpkgs/nixos-unstable"; + master.url = "github:nixos/nixpkgs/master"; digga.url = "github:divnix/digga"; digga.inputs.nixpkgs.follows = "nixos"; @@ -81,6 +82,7 @@ ]; }; latest = { }; + master = { }; }; lib = import ./lib { lib = digga.lib // nixos.lib; }; diff --git a/modules/sway/config/config.d/custom-keybindings.conf b/modules/sway/config/config.d/custom-keybindings.conf index d5887e3e..bedabb6c 100644 --- a/modules/sway/config/config.d/custom-keybindings.conf +++ b/modules/sway/config/config.d/custom-keybindings.conf @@ -23,7 +23,11 @@ bindsym $mod+F5 exec $term -e 'mocp -C $XDG_CONFIG_DIR/mocp/config' bindsym $mod+Shift+m exec mu bindsym $mod+Shift+h exec xdg-open /usr/share/doc/manjaro/i3_help.pdf -# Screenshofts +# Notifications with swaynotificationcenter +# Toggle control center +bindsym $mod+Shift+n exec swaync-client -t -sw + +# Screenshots bindsym $mod+Ctrl+p exec grim -g "$(slurp -d -b \#ffffff11)" ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png bindsym $mod+Shift+p exec grim ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png bindsym $mod+Ctrl+f exec "( pkill flameshot || true && flameshot & ) && ( sleep 0.5s && flameshot gui )" diff --git a/modules/sway/default.nix b/modules/sway/default.nix index 35013dd2..b327dfdf 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -60,6 +60,7 @@ in kanshi mako slurp + swaynotificationcenter swayidle swaylock swaybg @@ -85,7 +86,7 @@ in programs.waybar.enable = true; #programs.waybar.systemd.enable = true; - systemd.user.services.mako = import ./mako.service.nix pkgs; + systemd.user.services.swaynotificationcenter = import ./swaynotificationcenter.service.nix pkgs; systemd.user.services.sway = import ./sway.service.nix pkgs; systemd.user.services.swayidle = import ./swayidle.service.nix pkgs; systemd.user.services.xsettingsd = import ./xsettingsd.service.nix pkgs; diff --git a/modules/sway/mako.service.nix b/modules/sway/mako.service.nix deleted file mode 100644 index 190b986d..00000000 --- a/modules/sway/mako.service.nix +++ /dev/null @@ -1,20 +0,0 @@ -pkgs: -{ - Unit = { - Description = "Lightweight Wayland notification daemon"; - Documentation = [ "man:mako(1)" ]; - BindsTo = [ "sway-session.target" ]; - After = [ "sway-session.target" ]; - # ConditionEnvironment requires systemd v247 to work correctly - ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; - }; - Service = { - Type = "dbus"; - BusName = "org.freedesktop.Notifications"; - ExecStart = "${pkgs.mako}/bin/mako"; - ExecReload = "${pkgs.mako}/bin/makoctl reload"; - }; - Install = { - WantedBy = [ "sway-session.target" ]; - }; -} diff --git a/modules/sway/swaynotificationcenter.service.nix b/modules/sway/swaynotificationcenter.service.nix new file mode 100644 index 00000000..a0f57faf --- /dev/null +++ b/modules/sway/swaynotificationcenter.service.nix @@ -0,0 +1,22 @@ +pkgs: +{ + Unit = { + Description = "Swaync notification daemon"; + Documentation = "https://github.com/ErikReider/SwayNotificationCenter"; + BindsTo = [ "sway-session.target" ]; + After = [ "sway-session.target" ]; + Requisite = [ "graphical-session.target" ]; + # ConditionEnvironment requires systemd v247 to work correctly + ConditionEnvironment = [ "WAYLAND_DISPLAY" ]; + }; + Service = { + Type = "dbus"; + BusName = "org.freedesktop.Notifications"; + ExecStart = "${pkgs.swaynotificationcenter}/bin/swaync"; + ExecReload = "${pkgs.swaynotificationcenter}/bin/swaync-client --reload-config ; ${pkgs.swaynotificationcenter}/bin/swaync-client --reload-css"; + Restart = "on-failure"; + }; + Install = { + WantedBy = [ "sway-session.target" ]; + }; +} diff --git a/modules/sway/waybar.service.nix b/modules/sway/waybar.service.nix index ee5e8938..7f89a684 100644 --- a/modules/sway/waybar.service.nix +++ b/modules/sway/waybar.service.nix @@ -10,7 +10,7 @@ pkgs: Service = { Type = "dbus"; - Environment = "PATH=${pkgs.bash}/bin:${pkgs.pavucontrol}/bin"; + Environment = "PATH=${pkgs.bash}/bin:${pkgs.pavucontrol}/bin:${pkgs.swaynotificationcenter}/bin"; BusName = "fr.arouillard.waybar"; ExecStart = "${pkgs.waybar}/bin/waybar"; }; diff --git a/overlays/overrides.nix b/overlays/overrides.nix index 9b463e96..bf997eb3 100644 --- a/overlays/overrides.nix +++ b/overlays/overrides.nix @@ -27,6 +27,9 @@ channels: final: prev: { vimPlugins ; + inherit (channels.master) + swaynotificationcenter + ; haskellPackages = prev.haskellPackages.override (old: { diff --git a/profiles/base-user/.config/swaync/config.json b/profiles/base-user/.config/swaync/config.json new file mode 100644 index 00000000..06f7d024 --- /dev/null +++ b/profiles/base-user/.config/swaync/config.json @@ -0,0 +1,12 @@ +{ + "positionX": "right", + "positionY": "top", + "timeout": 10, + "timeout-low": 5, + "timeout-critical": 0, + "notification-window-width": 500, + "keyboard-shortcuts": true, + "image-visibility": "always", + "transition-time": 200, + "hide-on-clear": false +} diff --git a/profiles/base-user/.config/swaync/style.css b/profiles/base-user/.config/swaync/style.css new file mode 100644 index 00000000..2e33e7eb --- /dev/null +++ b/profiles/base-user/.config/swaync/style.css @@ -0,0 +1,149 @@ +/* + * vim: ft=less + */ + +@define-color border-color rgb(7, 7, 7); +@define-color bg rgb(58, 58, 58); +@define-color bg-hover rgb(68, 68, 68); +@define-color bg-focus rgba(68, 68, 68, 0.6); +@define-color bg-selected rgb(0, 128, 255); + +.notification-row { + outline: none; +} +.notification-row:focus, +.notification-row:hover { + background: @bg-focus; +} + +.notification { + border-radius: 10px; + margin: 6px 12px; + box-shadow: 0px 2px 4px 2px rgba(0, 0, 0, 0.3); + padding: 0; +} + +.notification-content { + background: transparent; + padding: 6px; + border-radius: 10px; +} + +.close-button { + background: black; + color: white; + text-shadow: none; + padding: 0 2px; + box-shadow: 0px 2px 4px 2px rgba(0, 0, 0, 0.3); + border-radius: 100%; +} +.close-button:hover { + background: rgb(30, 30, 30); + transition: all 0.15s ease-in-out; +} + +.notification-default-action, +.notification-action { + padding: 4px; + margin: 0; + box-shadow: none; + background: @bg; + border: 1px solid @border-color; +} + +.notification-default-action:hover, +.notification-action:hover { + background: @bg-hover; +} + +.notification-default-action { + border-radius: 10px; +} + +/* When alternative actions are visible */ +.notification-default-action:not(:only-child) { + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; +} + +.notification-action { + border-radius: 0px; + border-top: none; + border-right: none; +} + +/* add bottom border radius to eliminate clipping */ +.notification-action:first-child { + border-bottom-left-radius: 10px; +} +.notification-action:last-child { + border-bottom-right-radius: 10px; + border-right: 1px solid @border-color; +} + +.image { +} + +.body-image { + margin-top: 6px; + background-color: white; + border-radius: 10px; +} + +.summary { + color: white; + text-shadow: none; +} + +.time { + color: white; + text-shadow: none; +} + +.body { + background: transparent; + color: white; + text-shadow: none; +} + +.top-action-title { + color: white; + text-shadow: none; +} + +.control-center-clear-all { + color: white; + text-shadow: none; + background: @bg; + border: 1px solid @border-color; + box-shadow: none; + border-radius: 10px; +} +.control-center-clear-all:hover { + background: @bg-hover; +} + +.control-center-dnd { + border-radius: 10px; + background: @bg; + border: 1px solid @border-color; + box-shadow: none; +} + +.control-center-dnd:checked { + background: @bg-selected; +} +.control-center-dnd slider { + background: @bg-hover; +} + +.control-center { + background: rgba(0, 0, 0, 0.7); +} +.control-center-list { + background: transparent; +} + +.floating-notifications { + background: transparent; +} diff --git a/profiles/base-user/.config/waybar/config b/profiles/base-user/.config/waybar/config index 77bb74b8..9770b944 100644 --- a/profiles/base-user/.config/waybar/config +++ b/profiles/base-user/.config/waybar/config @@ -5,7 +5,16 @@ "height": 26, // Waybar height "modules-left": ["sway/workspaces", "sway/mode"], //"modules-center": ["mpd"], - "modules-right": ["sway/language", "pulseaudio", "network", "idle_inhibitor", "battery", "clock", "tray"], + "modules-right": [ + "sway/language", + "custom/notification", + "pulseaudio", + "network", + "idle_inhibitor", + "battery", + "clock", + "tray" + ], "sway/workspaces": { "disable-scroll": true }, @@ -98,5 +107,21 @@ }, "tooltip-format": "MPD (connected)", "tooltip-format-disconnected": "MPD (disconnected)" - } + }, + "custom/notification": { + "tooltip": false, + "format": " {icon}", + "format-icons": { + "notification": "", + "none": "", + "dnd-notification": "", + "dnd-none": "" + }, + "return-type": "json", + "exec-if": "which swaync-client", + "exec": "swaync-client -swb", + "on-click": "swaync-client -t -sw", + "on-click-right": "swaync-client -d -sw", + "escape": true + }, } diff --git a/profiles/base-user/.config/waybar/style.css b/profiles/base-user/.config/waybar/style.css index ef85a95a..b17cb0b0 100644 --- a/profiles/base-user/.config/waybar/style.css +++ b/profiles/base-user/.config/waybar/style.css @@ -14,7 +14,6 @@ window#waybar { color: @base04; } - #workspaces button { font-size: 14px; box-shadow: none; @@ -23,7 +22,6 @@ window#waybar { color: @base04; } - #workspaces button.focused { color: #f85e84; color: @base07; @@ -53,26 +51,29 @@ window#waybar { #battery.critical { color: @base07; } + #battery.charging { color: @base0B; } + #battery.full { margin: 0px 0px 0px 0px; } - #network { border-top: 1px solid transparent; } + #network.disconnected { margin: 0px 0px 0px 0px; color: rgba(75, 81, 98, 0); } - #pulseaudio.muted { margin: 0px 0px 0px 0px; color: rgba(75, 81, 98, 0); } - +#custom-notification { + font-family: "NotoSansMono Nerd Font"; +} diff --git a/profiles/base-user/.gitignore b/profiles/base-user/.gitignore index cd8e2eed..cd94a941 100644 --- a/profiles/base-user/.gitignore +++ b/profiles/base-user/.gitignore @@ -81,6 +81,10 @@ !/.config/waybar/config !/.config/waybar/style.css +!/.config/swaync +!/.config/swaync/config.json +!/.config/swaync/style.css + !/.config/mutt !/.config/mutt/muttrc !/.config/mutt/base16.muttrc diff --git a/profiles/base-user/home.nix b/profiles/base-user/home.nix index 1ae6bd36..be6d736c 100644 --- a/profiles/base-user/home.nix +++ b/profiles/base-user/home.nix @@ -43,6 +43,8 @@ in xdg.configFile."vifm/vifmrc".source = ./.config/vifm/vifmrc; xdg.configFile."vifm/colors/base16.vifm".source = ./.config/vifm/colors/base16.vifm; xdg.configFile."libinput-gestures.conf".source = ./.config/libinput-gestures.conf; + xdg.configFile."swaync/config.json".source = ./.config/swaync/config.json; + xdg.configFile."swaync/style.css".source = ./.config/swaync/style.css; xdg.configFile."waybar/config".source = ./.config/waybar/config; xdg.configFile."waybar/style.css".source = ./.config/waybar/style.css; xdg.configFile."waybar/colorscheme.css".source = ./.config/waybar/colorscheme.css;