From 4879c8321ffa17bb3c44fd0fdb6fbaf63db694da Mon Sep 17 00:00:00 2001 From: Jacob Bachmann Date: Tue, 19 Sep 2023 18:13:53 +0200 Subject: [PATCH] feat: add swaync, spotify, keyring --- modules/aliases.nix | 3 + modules/packages.nix | 2 + users/gandalf/modules/default.nix | 4 + users/gandalf/modules/keyring.nix | 16 + users/gandalf/modules/playerctl.nix | 13 + users/gandalf/modules/spotify-player/app.toml | 47 +++ .../modules/spotify-player/default.nix | 5 + .../modules/spotify-player/spotify-player.nix | 9 + users/gandalf/modules/sway.nix | 11 +- users/gandalf/modules/swaync/config.json | 94 +++++ users/gandalf/modules/swaync/default.nix | 5 + users/gandalf/modules/swaync/style.css | 340 ++++++++++++++++++ users/gandalf/modules/swaync/swaync.nix | 13 + users/gandalf/modules/zsh.nix | 3 + 14 files changed, 561 insertions(+), 4 deletions(-) create mode 100644 users/gandalf/modules/keyring.nix create mode 100644 users/gandalf/modules/playerctl.nix create mode 100644 users/gandalf/modules/spotify-player/app.toml create mode 100644 users/gandalf/modules/spotify-player/default.nix create mode 100644 users/gandalf/modules/spotify-player/spotify-player.nix create mode 100644 users/gandalf/modules/swaync/config.json create mode 100644 users/gandalf/modules/swaync/default.nix create mode 100644 users/gandalf/modules/swaync/style.css create mode 100644 users/gandalf/modules/swaync/swaync.nix diff --git a/modules/aliases.nix b/modules/aliases.nix index aabcb99..1d3495c 100644 --- a/modules/aliases.nix +++ b/modules/aliases.nix @@ -13,4 +13,7 @@ ta = "tmux attach"; ngc = "sudo nix-collect-garbage -d"; nec = "sudo -E nvim -u $HOME/.config/nvim/init.lua --cmd 'cd /etc/nixos'"; + ncc = "sudo nixos-rebuild switch --upgrade-all --flake /etc/nixos"; + nup = "sudo nix-channel --update && sudo nixos-rebuild switch --upgrade-all --flake /etc/nixos"; + spt = "spotify_player"; } diff --git a/modules/packages.nix b/modules/packages.nix index 4581b19..7ac2be7 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -11,6 +11,8 @@ lsd ripgrep expect # contains 'unbuffer' + # libs + libnotify # languages gcc13 go diff --git a/users/gandalf/modules/default.nix b/users/gandalf/modules/default.nix index 9632c5d..609d433 100644 --- a/users/gandalf/modules/default.nix +++ b/users/gandalf/modules/default.nix @@ -4,9 +4,13 @@ ./fzf.nix ./git.nix ./gnupg.nix + ./keyring.nix ./neovim.nix + ./playerctl.nix + ./spotify-player ./ssh.nix ./sway.nix + ./swaync ./tmux.nix ./udiskie.nix ./vscode.nix diff --git a/users/gandalf/modules/keyring.nix b/users/gandalf/modules/keyring.nix new file mode 100644 index 0000000..f87398b --- /dev/null +++ b/users/gandalf/modules/keyring.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: { + + services.gnome-keyring = { + enable = true; + components = [ + "pkcs11" + "secrets" + "ssh" + ]; + }; + + home.packages = with pkgs; [ + gnome.seahorse + ]; + +} diff --git a/users/gandalf/modules/playerctl.nix b/users/gandalf/modules/playerctl.nix new file mode 100644 index 0000000..11a93be --- /dev/null +++ b/users/gandalf/modules/playerctl.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: { + + home.packages = with pkgs; [ + playerctl + ]; + + /* + services.playerctld = { + enable = true; + }; + */ + +} diff --git a/users/gandalf/modules/spotify-player/app.toml b/users/gandalf/modules/spotify-player/app.toml new file mode 100644 index 0000000..74ea4c7 --- /dev/null +++ b/users/gandalf/modules/spotify-player/app.toml @@ -0,0 +1,47 @@ +theme = "dracula" +client_id = "65b708073fc0480ea92a077233ca87bd" +client_port = 8080 +playback_format = """ +{track} • {artists} +{album} +{metadata}""" +tracks_playback_limit = 50 +app_refresh_duration_in_ms = 32 +playback_refresh_duration_in_ms = 0 +cover_image_refresh_duration_in_ms = 2000 +page_size_in_rows = 20 +track_table_item_max_len = 32 +play_icon = "▶" +pause_icon = "▌▌" +liked_icon = "♥" +border_type = "Plain" +progress_bar_type = "Rectangle" +playback_window_position = "Top" +cover_img_length = 9 +cover_img_width = 5 +cover_img_scale = 1.0 +playback_window_width = 6 +enable_media_control = true +enable_streaming = true +enable_cover_image_cache = true +default_device = "spotify-player" + +[copy_command] +command = "xclip" +args = [ + "-sel", + "c", +] + +[notify_format] +summary = "{track} • {artists}" +body = "{album}" + +[device] +name = "spotify-player" +device_type = "speaker" +volume = 80 +bitrate = 320 +audio_cache = false + +# test diff --git a/users/gandalf/modules/spotify-player/default.nix b/users/gandalf/modules/spotify-player/default.nix new file mode 100644 index 0000000..a2a30d1 --- /dev/null +++ b/users/gandalf/modules/spotify-player/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./spotify-player.nix + ]; +} diff --git a/users/gandalf/modules/spotify-player/spotify-player.nix b/users/gandalf/modules/spotify-player/spotify-player.nix new file mode 100644 index 0000000..40a9a84 --- /dev/null +++ b/users/gandalf/modules/spotify-player/spotify-player.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: { + + home.packages = with pkgs; [ + spotify-player + ]; + + xdg.configFile."spotify-player/app.toml".source = ./app.toml; + +} diff --git a/users/gandalf/modules/sway.nix b/users/gandalf/modules/sway.nix index 643f799..22652d9 100644 --- a/users/gandalf/modules/sway.nix +++ b/users/gandalf/modules/sway.nix @@ -7,6 +7,7 @@ in home.packages = with pkgs; [ brightnessctl # control screen brightness pavucontrol # control audio + playerctl # control player networkmanagerapplet # control network dracula-theme # gtk theme gnome3.adwaita-icon-theme # default gnome cursors @@ -51,6 +52,7 @@ in startup = [ { command = "blueman-applet"; } { command = "nm-applet"; } + { command = "swaync"; } ]; input = { "2:7:SynPS/2_Synaptics_TouchPad" = { @@ -160,15 +162,16 @@ in "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl -q set 5%-"; "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl -q set 5%+"; - # "XF86AudioPrev" = "exec ${pkgs.mpc_cli}/bin/mpc -q next"; - # "XF86AudioNext" = "exec ${pkgs.mpc_cli}/bin/mpc -q prev"; - # "XF86AudioPlay" = "exec ${pkgs.mpc_cli}/bin/mpc -q toggle"; - # "XF86AudioPause" = "exec ${pkgs.mpc_cli}/bin/mpc -q toggle"; + "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; + "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; + "XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; + "XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; # Programs "${cfg.modifier}+Shift+v" = "exec ${pkgs.pavucontrol}/bin/pavucontrol"; "${cfg.modifier}+Shift+b" = "exec ${pkgs.blueman}/bin/blueman-manager"; "${cfg.modifier}+Shift+n" = "exec ${pkgs.networkmanagerapplet}/bin/nm-connection-editor"; + "${cfg.modifier}+Shift+a" = "exec ${pkgs.swaynotificationcenter}/bin/swaync-client -t -sw"; }; fonts = { names = [ common.font ]; diff --git a/users/gandalf/modules/swaync/config.json b/users/gandalf/modules/swaync/config.json new file mode 100644 index 0000000..49808f8 --- /dev/null +++ b/users/gandalf/modules/swaync/config.json @@ -0,0 +1,94 @@ +{ + "positionX": "right", + "positionY": "top", + "notification-icon-size": 64, + "notification-body-image-height": 100, + "notification-body-image-width": 200, + "timeout": 10, + "timeout-low": 5, + "timeout-critical": 0, + "fit-to-screen": true, + "keyboard-shortcuts": true, + "image-visibility": "when-available", + "transition-time": 200, + "hide-on-clear": false, + "hide-on-action": true, + "script-fail-notify": true, + "widgets": [ + "mpris", + "volume", + "backlight", + "title", + "dnd", + "notifications" + ], + "widget-config": { + "title": { + "text": "Notifications", + "clear-all-button": true, + "button-text": "Clear All" + }, + "dnd": { + "text": "Do Not Disturb" + }, + "label": { + "max-lines": 1, + "text": "Notification Center" + }, + "mpris": { + "image-size": 96, + "image-radius": 12 + }, + "volume": { + "label": "󰕾 " + }, + "backlight": { + "label": "󰃟 " + }, + "buttons-grid": { + "actions": [ + { + "label": "󰐥", + "command": "systemctl poweroff" + }, + { + "label": "󰜉", + "command": "systemctl reboot" + }, + { + "label": "󰌾", + "command": "swaylock" + }, + { + "label": "󰍃", + "command": "swaymsg exit" + }, + { + "label": "󰏥", + "command": "systemctl suspend" + }, + { + "label": "󰕾", + "command": "pactl set-sink-mute @DEFAULT_SINK@ toggle" + }, + { + "label": "󰍬", + "command": "pactl set-source-mute @DEFAULT_SOURCE@ toggle" + }, + { + "label": "󰖩", + "command": "iwgtk" + }, + { + "label": "󰂯", + "command": "blueman-manager" + }, + { + "label": "", + "command": "kooha" + } + ] + } + } +} + diff --git a/users/gandalf/modules/swaync/default.nix b/users/gandalf/modules/swaync/default.nix new file mode 100644 index 0000000..5072cdf --- /dev/null +++ b/users/gandalf/modules/swaync/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./swaync.nix + ]; +} diff --git a/users/gandalf/modules/swaync/style.css b/users/gandalf/modules/swaync/style.css new file mode 100644 index 0000000..3368575 --- /dev/null +++ b/users/gandalf/modules/swaync/style.css @@ -0,0 +1,340 @@ +@define-color cc-bg rgba(0, 0, 0, 1); +@define-color noti-border-color rgba(255, 255, 255, 0.15); +@define-color noti-bg rgb(17, 17, 27); +@define-color noti-bg-darker rgb(43, 43, 57); +@define-color noti-bg-hover rgb(27, 27, 43); +@define-color noti-bg-focus rgba(27, 27, 27, 0.6); +@define-color noti-close-bg rgba(255, 255, 255, 0.1); +@define-color noti-close-bg-hover rgba(255, 255, 255, 0.15); +@define-color text-color rgba(169, 177, 214, 1); +@define-color text-color-disabled rgb(150, 150, 150); +@define-color bg-selected rgb(0, 128, 255); + +* { + font-family: DejaVuSansM Nerd Font; + font-weight: bolder; +} + + + +.control-center .notification-row:focus, +.control-center .notification-row:hover { + opacity: 1; + background: @noti-bg-darker +} + +.notification-row { + outline: none; +} + +.notification { + border-radius: 12px; + margin: 10px; + padding: 0; + border: 2px solid #7aa2f7 +} + +.notification-content { + background: transparent; + padding: 10px; + border-radius: 12px +} + +.close-button { + background: @noti-close-bg; + color: @text-color; + text-shadow: none; + padding: 0; + border-radius: 100%; + margin-top: 10px; + margin-right: 16px; + box-shadow: none; + border: none; + min-width: 24px; + min-height: 24px +} + +.close-button:hover { + box-shadow: none; + background: @noti-close-bg-hover; + transition: all .15s ease-in-out; + border: none +} + +.notification-default-action, +.notification-action { + padding: 4px; + margin: 0; + box-shadow: none; + background: @noti-bg; + border: none; + color: @text-color; + transition: all .15s ease-in-out +} + +.notification-default-action:hover, +.notification-action:hover { + -gtk-icon-effect: none; + background: @noti-bg-hover +} + +.notification-default-action { + border-radius: 12px +} + +.notification-default-action:not(:only-child) { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0 +} + +.notification-action { + border-radius: 0; + border-top: none; + border-right: none +} + +.notification-action:first-child { + border-bottom-left-radius: 10px; + background: #1b1b2b +} + +.notification-action:last-child { + border-bottom-right-radius: 10px; + background: #1b1b2b +} + +.inline-reply { + margin-top: 8px +} + +.inline-reply-entry { + background: @noti-bg-darker; + color: @text-color; + caret-color: @text-color; + border: 1px solid @noti-border-color; + border-radius: 12px +} + +.inline-reply-button { + margin-left: 4px; + background: @noti-bg; + border: 1px solid @noti-border-color; + border-radius: 12px; + color: @text-color +} + +.inline-reply-button:disabled { + background: initial; + color: @text-color-disabled; + border: 1px solid transparent +} + +.inline-reply-button:hover { + background: @noti-bg-hover +} + +.body-image { + margin-top: 6px; + background-color: #fff; + border-radius: 12px +} + +.summary { + font-size: 16px; + font-weight: 700; + background: transparent; + color: rgba(158, 206, 106, 1); + text-shadow: none +} + +.time { + font-size: 16px; + font-weight: 700; + background: transparent; + color: @text-color; + text-shadow: none; + margin-right: 18px +} + +.body { + font-size: 15px; + font-weight: 400; + background: transparent; + color: @text-color; + text-shadow: none +} + +.control-center { + background: @cc-bg; + border: 1px solid #7aa2f7; + border-radius: 10px; +} + +.control-center-list { + background: transparent +} + +.control-center-list-placeholder { + opacity: .5 +} + +.floating-notifications { + background: transparent +} + +.blank-window { + background: alpha(black, 0.25) +} + +.widget-title { + color: @text-color; + margin: 10px; + font-size: 1.5rem +} + +.widget-title>button { + font-size: initial; + color: @text-color; + text-shadow: none; + background: @noti-bg; + border: 1px solid @noti-border-color; + box-shadow: none; + border-radius: 12px +} + +.widget-title>button:hover { + background: @noti-bg-hover +} + +.widget-dnd { + color: @text-color; + margin: 10px; + font-size: 1.1rem +} + +.widget-dnd>switch { + font-size: initial; + border-radius: 12px; + background: @noti-bg; + border: 1px solid @noti-border-color; + box-shadow: none +} + +.widget-dnd>switch:checked { + background: @bg-selected +} + +.widget-dnd>switch slider { + background: @noti-bg-hover; + border-radius: 12px +} + +.widget-label { + margin: 10px; +} + +.widget-label>label { + font-size: 1.5rem; + color: @text-color; +} + +.widget-mpris { + color: @text-color; + background: @noti-bg-darker; + padding: 10px; + margin: 10px; + border-radius: 10px; +} + +.widget-mpris-player { + padding: 8px; + margin: 8px +} + +.widget-mpris-title { + font-weight: 700; + font-size: 1.25rem +} + +.widget-mpris-subtitle { + font-size: 1.1rem +} + +.widget-buttons-grid { + font-size: x-large; + padding: 8px; + margin: 20px 10px 10px; + border-radius: 12px; + background: @noti-bg-darker; +} + +.widget-buttons-grid>flowbox>flowboxchild>button { + margin: 3px; + background: #343b58; + border-radius: 12px; + color: @text-color +} + +.widget-buttons-grid>flowbox>flowboxchild>button:hover { + /* background: @noti-bg-hover; */ + color: rgba(158, 206, 106, 1) +} + +.widget-menubar>box>.menu-button-bar>button { + border: none; + background: transparent +} + +.topbar-buttons>button { + border: none; + background: transparent +} + +.widget-volume { + background: @noti-bg-darker; + padding: 8px; + margin: 10px; + border-radius: 12px; + font-size: x-large; + color: @text-color +} + +.widget-volume>box>button { + background: transparent; + border: none +} + +.per-app-volume { + background-color: @noti-bg; + padding: 4px 8px 8px; + margin: 0 8px 8px; + border-radius: 12px +} + +.widget-backlight { + background: @noti-bg-darker; + padding: 8px; + margin: 10px; + border-radius: 12px; + font-size: x-large; + color: @text-color +} + +.widget-inhibitors { + margin: 8px; + font-size: 1.5rem +} + +.widget-inhibitors>button { + font-size: initial; + color: @text-color; + text-shadow: none; + background: @noti-bg; + border: 1px solid @noti-border-color; + box-shadow: none; + border-radius: 12px +} + +.widget-inhibitors>button:hover { + background: @noti-bg-hover +} diff --git a/users/gandalf/modules/swaync/swaync.nix b/users/gandalf/modules/swaync/swaync.nix new file mode 100644 index 0000000..e75dfaf --- /dev/null +++ b/users/gandalf/modules/swaync/swaync.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: { + + home.packages = with pkgs; [ + swaynotificationcenter + libnotify + ]; + + xdg.configFile = { + "swaync/config.json".source = ./config.json; + "swaync/style.css".source = ./style.css; + }; + +} diff --git a/users/gandalf/modules/zsh.nix b/users/gandalf/modules/zsh.nix index a636de2..8389d97 100644 --- a/users/gandalf/modules/zsh.nix +++ b/users/gandalf/modules/zsh.nix @@ -3,6 +3,8 @@ enable = true; enableCompletion = true; enableAutosuggestions = true; + syntaxHighlighting.enable = true; + /* plugins = [ { name = "zsh-syntax-highlighting"; @@ -14,6 +16,7 @@ }; } ]; + */ oh-my-zsh = { enable = true; theme = "terminalparty";