From ecdab71a09490e4fd2f656e13fc09c3b344e3f04 Mon Sep 17 00:00:00 2001
From: Nate Anderson <nate.anderson@vasion.com>
Date: Mon, 6 Jan 2025 16:00:23 -0700
Subject: [PATCH] Added better bluetooth headphone setup, starting pollkit
 agent, better screenshot script

---
 nate-work/desktop-configuration.nix           |  1 -
 nate-work/dotfiles/code-flags.conf            |  2 ++
 nate-work/dotfiles/electron-flags.conf        |  2 ++
 nate-work/dotfiles/electron12-flags.conf      |  2 ++
 nate-work/dotfiles/hypr/scripts/screenshot.sh | 18 ++++++++++---
 nate-work/dotfiles/wofi/config.screenshot     |  1 +
 nate-work/modules/home-manager/home.nix       |  7 +++---
 nate-work/modules/hypr/hypr_home.nix          | 25 ++++++++-----------
 nate-work/modules/hypr/hyprland.nix           | 19 +++++++++++---
 9 files changed, 50 insertions(+), 27 deletions(-)
 create mode 100644 nate-work/dotfiles/code-flags.conf
 create mode 100644 nate-work/dotfiles/electron-flags.conf
 create mode 100644 nate-work/dotfiles/electron12-flags.conf

diff --git a/nate-work/desktop-configuration.nix b/nate-work/desktop-configuration.nix
index a165d0d..c63d09a 100644
--- a/nate-work/desktop-configuration.nix
+++ b/nate-work/desktop-configuration.nix
@@ -74,7 +74,6 @@ in
         installGaming = deskCfg.installGaming;
         systemPackages = with pkgs; [
           libreoffice
-          rpi-imager
         ];
     };
 
diff --git a/nate-work/dotfiles/code-flags.conf b/nate-work/dotfiles/code-flags.conf
new file mode 100644
index 0000000..51bdd86
--- /dev/null
+++ b/nate-work/dotfiles/code-flags.conf
@@ -0,0 +1,2 @@
+--enable-features=UseOzonePlatform
+--ozone-platform=wayland
diff --git a/nate-work/dotfiles/electron-flags.conf b/nate-work/dotfiles/electron-flags.conf
new file mode 100644
index 0000000..51bdd86
--- /dev/null
+++ b/nate-work/dotfiles/electron-flags.conf
@@ -0,0 +1,2 @@
+--enable-features=UseOzonePlatform
+--ozone-platform=wayland
diff --git a/nate-work/dotfiles/electron12-flags.conf b/nate-work/dotfiles/electron12-flags.conf
new file mode 100644
index 0000000..51bdd86
--- /dev/null
+++ b/nate-work/dotfiles/electron12-flags.conf
@@ -0,0 +1,2 @@
+--enable-features=UseOzonePlatform
+--ozone-platform=wayland
diff --git a/nate-work/dotfiles/hypr/scripts/screenshot.sh b/nate-work/dotfiles/hypr/scripts/screenshot.sh
index 71c672a..33d848a 100755
--- a/nate-work/dotfiles/hypr/scripts/screenshot.sh
+++ b/nate-work/dotfiles/hypr/scripts/screenshot.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
  
-entries="Screen Window Area"
+entries="Screen Window Area Area+Edit"
  
 selected=$(printf '%s\n' "$entries" | tr ' ' '\n' | wofi --style="$HOME"/.config/wofi/macc_style.css --conf="$HOME"/.config/wofi/config.screenshot | awk '{print tolower($1)}')
 
@@ -12,14 +12,24 @@ if [ "$1" == "clipboard" ]; then
       hyprshot --notif-timeout 2000 -m window --clipboard-only;;
     area)
       hyprshot --notif-timeout 2000 -m region --clipboard-only;;
+    area+edit)
+      hyprshot --notif-timeout 2000 -m region --clipboard-only
+      sleep 0.1
+      flatpak run com.github.maoschanz.drawing -c
+      ;;
   esac
 else 
   case $selected in
     screen)
-      hyprshot --notif-timeout 2000 -m output -o ~/;;
+      hyprshot --notif-timeout 2000 -m output -o ~/Pictures/;;
     window)
-      hyprshot --notif-timeout 2000 -m window -o ~/;;
+      hyprshot --notif-timeout 2000 -m window -o ~/Pictures/;;
     area)
-      hyprshot --notif-timeout 2000 -m region -o ~/;;
+      hyprshot --notif-timeout 2000 -m region -o ~/Pictures/;;
+    area+edit)
+      hyprshot --notif-timeout 2000 -m region --clipboard-only
+      sleep 0.1
+      flatpak run com.github.maoschanz.drawing -c
+      ;;
   esac
 fi
diff --git a/nate-work/dotfiles/wofi/config.screenshot b/nate-work/dotfiles/wofi/config.screenshot
index a323e59..d895aca 100644
--- a/nate-work/dotfiles/wofi/config.screenshot
+++ b/nate-work/dotfiles/wofi/config.screenshot
@@ -6,3 +6,4 @@ show=dmenu
 location=top_right
 x=-200
 y=60
+prompt="Screenshot"
diff --git a/nate-work/modules/home-manager/home.nix b/nate-work/modules/home-manager/home.nix
index bd98e94..a6c37f8 100644
--- a/nate-work/modules/home-manager/home.nix
+++ b/nate-work/modules/home-manager/home.nix
@@ -94,6 +94,7 @@
       cli-visualizer
       openscad
       libxml2
+      nfs-utils
 
       #
       # Better Unix
@@ -118,11 +119,9 @@
       #
       # Photo / Video
       #
-      # oldstable.davinci-resolve-studio
-      # davinciDesktop
+      davinci-resolve-studio
       imv
       mpv
-      gimp
       ffmpeg
       tenacity
       yt-dlp
@@ -179,6 +178,8 @@
     enable = true;
     indicator = true;
   };
+  # Enable bluetooth headphone controls
+  services.mpris-proxy.enable = true;
 
   home.sessionVariables = {
     # BAT_THEME="Catppuccin Macchiato";
diff --git a/nate-work/modules/hypr/hypr_home.nix b/nate-work/modules/hypr/hypr_home.nix
index 3eb9ae6..914202a 100644
--- a/nate-work/modules/hypr/hypr_home.nix
+++ b/nate-work/modules/hypr/hypr_home.nix
@@ -1,7 +1,7 @@
 { inputs, lib, config, pkgs, ... }:
-# let 
+let
 #   unstable = import inputs.nixpkgs-unstable { system = "x86_64-linux"; config.allowUnfree = true; };
-# in
+in
 {
   options.hyprhome = {
     enable = lib.mkEnableOption "Enable hyprland home config";
@@ -29,6 +29,7 @@
           "sleep 5 && syncthingtray --wait"
           "blueman-applet"
           "hypridle"
+          "lxqt-policykit-agent"
           # May need to kill mako if nwg-panel starts it
           "swaync"
           "keepassxc"
@@ -143,12 +144,12 @@
       bindel = [
         # Brightness / Volume Controls
         # Chromebook has the printed symbols for these actions, but are really just fn keys
-        "$mod, XF86MonBrightnessDown, exec, brightnessctl s 10%-"
-        "$mod, XF86MonBrightnessUp, exec, brightnessctl s 10%+"
-        "$mod, XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
-        "$mod, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"
-        "$mod, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"
-        "$mod, XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
+        ", XF86MonBrightnessDown, exec, brightnessctl s 10%-"
+        ", XF86MonBrightnessUp, exec, brightnessctl s 10%+"
+        ", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"
+        ", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"
+        ", XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"
+        ", XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"
       ];
       # Lid switch binds
       bindl = [
@@ -159,12 +160,6 @@
         ", switch:off:Lid Switch, exec, hyprctl keyword monitor 'eDP-1, 2560x1600@165, 0x0, 1.00' && nwg-panel"
         # ", switch:off:[switch name], exec, hyprctl dispatch dpms on eDP-1"
       ];
-      # env = [
-        # "XCURSOR_THEME,catppuccin-macchiato-lavender-cursors"
-        # "XCURSOR_SIZE,24"
-        # "HYPRCURSOR_THEME,catppuccin-macchiato-lavender-cursors"
-        # "HYPRCURSOR_SIZE,24"
-      # ];
       windowrulev2 = [
         # float keepass windows, put main window in scratch
         "float, class:^(org.keepassxc.KeePassXC)$"
@@ -186,7 +181,7 @@
         ", preferred, auto, 1"
       ];
       cursor = {
-        no_hardware_cursors = false;
+        no_hardware_cursors = true;
         # allow_dumb_copy = true;
       };
       misc = {
diff --git a/nate-work/modules/hypr/hyprland.nix b/nate-work/modules/hypr/hyprland.nix
index a929a20..ba38966 100644
--- a/nate-work/modules/hypr/hyprland.nix
+++ b/nate-work/modules/hypr/hyprland.nix
@@ -1,6 +1,7 @@
 { inputs, lib, config, pkgs, ...}:
 let 
   unstable = import inputs.nixpkgs-unstable { system = "x86_64-linux"; config.allowUnfree = true; };
+  isOnTheGo = builtins.elem "on-the-go" config.system.nixos.tags;
 in
 {
   options.hypr = {
@@ -58,8 +59,9 @@ in
         GDK_BACKEND = "wayland";
         WLR_NO_HARDWARE_CURSORS = "1";
         # For hyprland
-        # LIBVA_DRIVER_NAME = "nvidia";
-        # __GLX_VENDOR_LIBRARY_NAME = "nvidia";
+        # Only enable if not using on-the-go
+        GBM_BACKEND = if isOnTheGo then "" else "nvidia-drm";
+        __GLX_VENDOR_LIBRARY_NAME = if isOnTheGo then "" else "nvidia";
       };
     };
     xdg.portal = {
@@ -125,18 +127,27 @@ in
     services.logind.lidSwitchExternalPower = "ignore";
     # For yubioath desktop
     services.pcscd.enable = true;
-    # Audio
-    # security.rtkit.enable = true;
     security.polkit.enable = true;
     # Keyring setup
     security.pam.services.gdm.enableGnomeKeyring = true;
     services.gnome.gnome-keyring.enable = true;
     # Audio
+    security.rtkit.enable = true;
     services.pipewire = {
       enable = true;
+      audio.enable = true;
       alsa.enable = true;
+      alsa.support32Bit = true;
       pulse.enable = true;
       wireplumber.enable = true;
+      wireplumber.extraConfig.bluetoothEnhancements = {
+        "monitor.bluez.properties" = {
+            "bluez5.enable-sbc-xq" = true;
+            "bluez5.enable-msbc" = true;
+            "bluez5.enable-hw-volume" = true;
+            "bluez5.roles" = [ "hsp_hs" "hsp_ag" "hfp_hf" "hfp_ag" "a2dp_sink" "a2dp_source" ];
+        };
+      };
     };
     services.blueman.enable = true;
     services.flatpak.enable = true;