From a3421d4e370806e9284817ad9b88f5a6f68f1763 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Fri, 20 Sep 2024 02:07:32 +0200
Subject: [PATCH] Add scripts for handling HiDPI

---
 lib/modules/valhalla.nix                      |  6 +++++
 .../machines/manuel/ManuSurface/config.nix    |  1 +
 scripts/Arch/Scripts/deploy.fish              |  2 +-
 scripts/Arch/Software/steam/main.fish         | 24 +++++++++++++++++++
 4 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 scripts/Arch/Software/steam/main.fish

diff --git a/lib/modules/valhalla.nix b/lib/modules/valhalla.nix
index 316d94d0..9870fa61 100644
--- a/lib/modules/valhalla.nix
+++ b/lib/modules/valhalla.nix
@@ -72,6 +72,12 @@
           description = "The X11 keyboard layout of the system.";
           default = null;
         };
+
+        hidpi = mkOption {
+          type = types.bool;
+          description = "A value indicating whether the screen is hidpi.";
+          default = false;
+        };
       };
     };
   }
diff --git a/profiles/machines/manuel/ManuSurface/config.nix b/profiles/machines/manuel/ManuSurface/config.nix
index c9e56677..827ae7d9 100644
--- a/profiles/machines/manuel/ManuSurface/config.nix
+++ b/profiles/machines/manuel/ManuSurface/config.nix
@@ -6,6 +6,7 @@
   config = {
     valhalla = {
       hostname = "manu-surface";
+      hidpi = true;
       linux.secureBoot = true;
 
       hardware = {
diff --git a/scripts/Arch/Scripts/deploy.fish b/scripts/Arch/Scripts/deploy.fish
index 5aea0650..8dddd934 100644
--- a/scripts/Arch/Scripts/deploy.fish
+++ b/scripts/Arch/Scripts/deploy.fish
@@ -275,7 +275,6 @@ function deploySoftware -d "Deploys a the specified software action" -a action
     and if collectionActive gaming
         if $isInstall
             yayinst \
-                steam \
                 chiaki-ng \
                 osu-lazer-bin \
                 libretro \
@@ -286,6 +285,7 @@ function deploySoftware -d "Deploys a the specified software action" -a action
         end
 
         and source "$dir/../Software/Lutris/main.fish" $argv
+        and source "$dir/../Software/steam/main.fish" $argv
     end
 
     and if collectionActive essential && $isInstall
diff --git a/scripts/Arch/Software/steam/main.fish b/scripts/Arch/Software/steam/main.fish
new file mode 100644
index 00000000..f645bc2c
--- /dev/null
+++ b/scripts/Arch/Software/steam/main.fish
@@ -0,0 +1,24 @@
+#!/bin/env fish
+begin
+    set -l dir (status dirname)
+    source "$dir/../../Scripts/software.fish"
+
+    function installSW
+        yayinst steam
+    end
+
+
+    function configureSW -V dir
+        . "$dir/../../../Common/Scripts/config.fish"
+
+        if isEnabled valhalla.hidpi
+            begin
+                printf %s\n \
+                    "#!/bin/bash" \
+                    "export STEAM_FORCE_DESKTOPUI_SCALING=2.0"
+            end | sudo tee /etc/profile.d/steam.sh > /dev/null
+        end
+    end
+
+    runInstaller $argv
+end