diff --git a/config/grapheio/scripts/volume.sh b/config/grapheio/scripts/volume.sh new file mode 100755 index 0000000..dd7c5cc --- /dev/null +++ b/config/grapheio/scripts/volume.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Dependencies: +# - amixer +# - pactl +# - jq +# - libnotify + +ACTION=$1 + +get_volume_info() { + amixer sget Master | \ + grep 'Left:' | \ + sed -e 's/[^[]*\[\([0-9]*\)%\][^[]\[\(\w*\)\]/{"volume": \1, "muted": \2}/' \ + -e 's/on/false/' \ + -e 's/off/true/' +} + +notify() { + notify-send "$1" "$2" -e -t 1500 -h string:x-canonical-private-synchronous:volume +} + +mute() { + pactl set-sink-mute @DEFAULT_SINK@ toggle + + VOLUME_INFO=$(get_volume_info) + VOLUME=$(echo $VOLUME_INFO | jq .volume) + if [ $(echo $VOLUME_INFO | jq .muted) == "true" ] + then + AUDIO_ICON="󰝟" + MUTED_STR="Muted" + BODY="" + else + AUDIO_ICON="󰕾" + MUTED_STR="Unmuted" + BODY=$(echo "$VOLUME%") + fi + + TITLE=$(echo "$AUDIO_ICON $MUTED_STR") + notify "$TITLE" "$BODY" +} + +set_volume() { + # Set the volume + TARGET=$1 + pactl set-sink-volume @DEFAULT_SINK@ $TARGET + + # Send a notification + VOLUME_INFO=$(get_volume_info) + ACTION=$([[ ${TARGET:0:1} == "+" ]] && echo "Volume Up" || echo "Volume Down") + VOLUME=$(echo $VOLUME_INFO | jq .volume) + + if [ $(echo $VOLUME_INFO | jq .muted) == "true" ] + then + AUDIO_ICON="󰝟" + MUTED_STR="[muted]" + else + AUDIO_ICON="󰕾" + MUTED_STR="" + fi + + TITLE=$(echo "$AUDIO_ICON $ACTION") + BODY=$(echo "$VOLUME% $MUTED_STR") + notify "$TITLE" "$BODY" +} + +case $ACTION in + mute) + mute + ;; + set) + set_volume $2 + ;; + *) + echo "Unknown action" + exit 1 + ;; +esac + diff --git a/modules/desktop/grapheio.nix b/modules/desktop/grapheio.nix index 2012a6d..409d8da 100644 --- a/modules/desktop/grapheio.nix +++ b/modules/desktop/grapheio.nix @@ -3,6 +3,7 @@ with lib; let cfg = config.samfelag.modules.desktop.grapheio; + hyprCfg = config.samfelag.modules.desktop.wm.hyprland; in { options.samfelag.modules.desktop.grapheio = { @@ -14,11 +15,19 @@ in # - Packages --------------------------------- environment.systemPackages = with pkgs; [ + # - Tools ---------------------------------- + jq # - Appearance ----------------------------- + rose-pine-gtk-theme + rose-pine-icon-theme # - Cursor inputs.hyprcursor-rose-pine.packages.${pkgs.system}.default + rose-pine-cursor ]; + # - Data files ------------------------------- + hm.xdg.configFile."grapheio".source = ../../config/grapheio; + # - Cursor ----------------------------------- hm.home.pointerCursor = { gtk.enable = true; @@ -29,12 +38,42 @@ in hm.gtk = { enable = true; + theme = { + package = pkgs.rose-pine-gtk-theme; + name = "rose-pine-gtk-theme"; + }; + iconTheme = { + package = pkgs.rose-pine-icon-theme; + name = "rose-pine-icons"; + }; cursorTheme = { package = pkgs.rose-pine-cursor; - name = "BreezeX Cursor"; + name = "BreezeX-RoséPine"; + size = 24; }; }; + # - Hyprland keybindings --------------------- + hm.wayland.windowManager.hyprland.settings = lib.mkIf hyprCfg.enable { + bind = [ + # Pulse Audio controls (mute) + ", XF86AudioMute, exec, $HOME/.config/grapheio/scripts/volume.sh mute" + + # Media player controls + ", XF86AudioPlay, exec, playerctl play-pause" + ", XF86AudioPause, exec, playerctl play-pause" + ", XF86AudioNext, exec, playerctl next" + ", XF86AudioPrev, exec, playerctl previous" + ", XF86AudioStop, exec, playerctl stop" + ]; + + binde = [ + # Pulse Audio controls (volume) + ", XF86AudioRaiseVolume, exec, $HOME/.config/grapheio/scripts/volume.sh set +5%" + ", XF86AudioLowerVolume, exec, $HOME/.config/grapheio/scripts/volume.sh set -5%" + ]; + }; + # - Modules ---------------------------------- samfelag.modules = { diff --git a/modules/desktop/tools/swaync.nix b/modules/desktop/tools/swaync.nix index fac48f8..d0c7e4d 100644 --- a/modules/desktop/tools/swaync.nix +++ b/modules/desktop/tools/swaync.nix @@ -19,30 +19,83 @@ in { hm.services.swaync = { enable = true; settings = { + widgets = [ + "title" + "dnd" + "notifications" + ]; + widget-config = { + dnd = { + text = "Silence"; + }; + title = { + text = "Notifications"; + clear-all-button = true; + button-text = "󰆴"; + }; + }; }; style = '' * { font-family: Iosevka; + color: #${config.colorScheme.palette.base05}; } .notification { - padding: 4px 4px 0px 4px; + border-width: 2px; + padding: 2px 4px; background-color: #${config.colorScheme.palette.base00}; color: #${config.colorScheme.palette.base05}; } - .summary { + .notification-content { + background-color: inherit; + color: inherit; } - .body { + .critical.notification { + background-color: #${config.colorScheme.palette.base0C}; + } + + .image { + margin: 5px; + padding-right: 5px; } .control-center { - margin: 20px; - opacity: 0.95; + margin: 30px; + margin-left: 0px; + border-radius: 10px; + border: solid #${config.colorScheme.palette.base05} 1px; background-color: #${config.colorScheme.palette.base01}; color: #${config.colorScheme.palette.base05}; + opacity: 0.95; } + + .control-center-clear-all { + background: #${config.colorScheme.palette.base02}; + } + + .control-center-dnd:checked { + background: #${config.colorScheme.palette.base08}; + } + + .close-button { + background: #${config.colorScheme.palette.base08}; + } + + .notification-group-collapse-button { + margin: 4px; + box-shadow: none; + background: #${config.colorScheme.palette.base0A}; + } + + .notification-group-close-all-button { + margin: 4px; + box-shadow: none; + background: #${config.colorScheme.palette.base08}; + } + ''; }; @@ -53,6 +106,11 @@ in { "swaync" ]; + layerrule = [ + "animation slide top, swaync-control-center" + "animation slide top, swaync-notification-window" + ]; + bind = [ # Notification center "${hyprCfg.mod}, n, exec, swaync-client -t -sw" diff --git a/modules/system/audio.nix b/modules/system/audio.nix index e9bf6e0..dc74941 100644 --- a/modules/system/audio.nix +++ b/modules/system/audio.nix @@ -19,26 +19,5 @@ in ]; services.pipewire.enable = true; - - # - Hyprland keybindings --------------------- - hm.wayland.windowManager.hyprland.settings = lib.mkIf hyprCfg.enable { - bind = [ - # Pulse Audio controls (mute) - ", XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle" - - # Media player controls - ", XF86AudioPlay, exec, playerctl play-pause" - ", XF86AudioPause, exec, playerctl play-pause" - ", XF86AudioNext, exec, playerctl next" - ", XF86AudioPrev, exec, playerctl previous" - ", XF86AudioStop, exec, playerctl stop" - ]; - - binde = [ - # Pulse Audio controls (volume) - ", XF86AudioRaiseVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ +5%" - ", XF86AudioLowerVolume, exec, pactl set-sink-volume @DEFAULT_SINK@ -5%" - ]; - }; }; } diff --git a/modules/system/bluetooth.nix b/modules/system/bluetooth.nix index 85d0482..05661b2 100644 --- a/modules/system/bluetooth.nix +++ b/modules/system/bluetooth.nix @@ -2,7 +2,6 @@ let cfg = config.samfelag.modules.system.bluetooth; - desktopCfg = config.samfelag.modules.desktop; in { options.samfelag.modules.system.bluetooth = { @@ -11,9 +10,5 @@ in config = lib.mkIf cfg.enable { hardware.bluetooth.enable = true; services.blueman.enable = true; - - samfelag.modules.desktop.wm.i3.extraKeybindings = lib.mkIf desktopCfg.enable { - "${desktopCfg.i3.mod}+b" = "exec $HOME/.config/rofi/menus/bluetooth/bluetooth.sh"; - }; }; }