From ed15864d22ca286a8f62b88f9aa44ff3ac50e8ee Mon Sep 17 00:00:00 2001 From: Ray Andrew Date: Sat, 16 Nov 2024 23:58:28 -0600 Subject: [PATCH] fix multi DPI scaling in x11 using xsession --- src/home/gui/gnome.nix | 3 +- src/home/shell/bash.nix | 6 ++-- src/home/shell/neovim/config/init.lua | 13 +++++++ src/home/shell/neovim/config/lazy-lock.json | 1 + src/home/wm/default.nix | 5 ++- src/home/wm/i3.nix | 40 +++++++++++++++------ src/hosts/default.nix | 1 + src/hosts/pickwick/default.nix | 2 +- src/nixos/displaymanager.nix | 14 ++++++-- 9 files changed, 66 insertions(+), 19 deletions(-) diff --git a/src/home/gui/gnome.nix b/src/home/gui/gnome.nix index da3f9af..ec0cbf6 100644 --- a/src/home/gui/gnome.nix +++ b/src/home/gui/gnome.nix @@ -2,6 +2,7 @@ lib, pkgs, config, + wallpaper, ... }: { @@ -117,7 +118,7 @@ toggle-stacking-global = [ "s" ]; }; "org/gnome/desktop/background" = { - picture-uri-dark = "file://${pkgs.nixos-artwork.wallpapers.nineish-dark-gray.src}"; + picture-uri-dark = "file://${wallpaper}"; }; "org/gnome/desktop/interface" = { color-scheme = "prefer-dark"; diff --git a/src/home/shell/bash.nix b/src/home/shell/bash.nix index c7e074f..532c34b 100644 --- a/src/home/shell/bash.nix +++ b/src/home/shell/bash.nix @@ -7,9 +7,9 @@ { programs.bash.enable = true; programs.bash.enableVteIntegration = true; - programs.bash.initExtra = lib.mkAfter '' - export NIX_LD=$(nix eval --impure --raw --expr 'let pkgs = import {}; NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; in NIX_LD') - ''; + # programs.bash.initExtra = lib.mkAfter '' + # export NIX_LD=$(nix eval --impure --raw --expr 'let pkgs = import {}; NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; in NIX_LD') + # ''; programs.bash.bashrcExtra = lib.mkAfter '' if [ "$term" != "dumb" ] || [ -n "$inside_emacs" ]; then prompt_color="1;32m" diff --git a/src/home/shell/neovim/config/init.lua b/src/home/shell/neovim/config/init.lua index 7f6b305..773f705 100644 --- a/src/home/shell/neovim/config/init.lua +++ b/src/home/shell/neovim/config/init.lua @@ -943,6 +943,19 @@ require("lazy").setup({ }, }, }, + { + "ojroques/nvim-osc52", + event = "VimEnter", + config = function() + local copy = function() + if vim.v.event.operator == "y" and vim.v.event.regname == "+" then + require("osc52").copy_register("+") + end + end + + vim.api.nvim_create_autocmd("TextYankPost", { callback = copy }) + end, + }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/src/home/shell/neovim/config/lazy-lock.json b/src/home/shell/neovim/config/lazy-lock.json index 39fe159..85e6daa 100644 --- a/src/home/shell/neovim/config/lazy-lock.json +++ b/src/home/shell/neovim/config/lazy-lock.json @@ -19,6 +19,7 @@ "multicursor.nvim": { "branch": "1.0", "commit": "b715cc5bf69cf6e338899510eb2b60b1dd7ccce0" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-lspconfig": { "branch": "master", "commit": "87c7c83ce62971e0bdb29bb32b8ad2b19c8f95d0" }, + "nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" }, "nvim-treesitter": { "branch": "master", "commit": "20e10ca6914f65cf1410232433fb58de70ab6b39" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "oil.nvim": { "branch": "master", "commit": "8ea40b5506115b6d355e304dd9ee5089f7d78601" }, diff --git a/src/home/wm/default.nix b/src/home/wm/default.nix index c42023f..281bb3a 100644 --- a/src/home/wm/default.nix +++ b/src/home/wm/default.nix @@ -6,6 +6,9 @@ _: { ]; config = { - xsession.enable = true; + xsession = { + enable = true; + scriptPath = ".xsession-hm"; + }; }; } diff --git a/src/home/wm/i3.nix b/src/home/wm/i3.nix index 0b8224c..6956c1c 100644 --- a/src/home/wm/i3.nix +++ b/src/home/wm/i3.nix @@ -2,6 +2,7 @@ pkgs, lib, config, + wallpaper, ... }: let @@ -30,9 +31,11 @@ in }; config = lib.mkIf config.custom.wm.i3.enable { - home.packages = with pkgs; [ arandr + feh + xfce.xfce4-volumed-pulse + autorandr ]; services.picom = { enable = true; @@ -40,15 +43,15 @@ in services.dunst = { enable = true; }; - # xsession.profileExtra = '' - # export GDK_SCALE=2 - # export GDK_DPI_SCALE=0.5 - # export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2" - # export QT_AUTO_SCREEN_SCALE_FACTOR=1 - # export QT_DEVICE_PIXEL_RATIO=2 - # echo "Xft.dpi: 192" | xrdb -merge - # export XCURSOR_SIZE=64 - # ''; + xsession.initExtra = '' + export GDK_SCALE=2 + export GDK_DPI_SCALE=0.5 + export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2" + export QT_AUTO_SCREEN_SCALE_FACTOR=1 + export QT_DEVICE_PIXEL_RATIO=2 + echo "Xft.dpi: 192" | xrdb -merge + export XCURSOR_SIZE=64 + ''; xsession.windowManager.i3 = { enable = true; extraConfig = commonOptions.extraConfig; @@ -69,6 +72,23 @@ in "${commonOptions.modifier}+Shift+o" = "exec --no-startup-id ${maim} -s | ${clipboard-copy} -selection clipboard -t image/png"; "PRINT" = "exec --no-startup-id ${maim} -s | ${clipboard-copy} -selection clipboard -t image/png"; }; + startup = [ + { + command = "autorandr -c"; + always = false; # Important, run only on first start (will loop otherwise)! + notification = false; + } + { + command = "feh --bg-fill ${wallpaper}"; + always = true; + notification = false; + } + { + command = "xfce4-volumed-pulse &"; + always = false; + notification = false; + } + ]; } ]; }; diff --git a/src/hosts/default.nix b/src/hosts/default.nix index bf007b6..e40a164 100644 --- a/src/hosts/default.nix +++ b/src/hosts/default.nix @@ -40,6 +40,7 @@ let extraSpecialArgs = specialArgs // { inherit host user; dots = "/home/${user}/code/nix-config"; + wallpaper = pkgs.nixos-artwork.wallpapers.nineish-dark-gray.src; }; users.${user} = { diff --git a/src/hosts/pickwick/default.nix b/src/hosts/pickwick/default.nix index 9d9df4b..31ad7d3 100644 --- a/src/hosts/pickwick/default.nix +++ b/src/hosts/pickwick/default.nix @@ -47,7 +47,7 @@ bluetooth.enable = true; wm = { i3.enable = true; - sway.enable = true; + sway.enable = false; }; gnome = { enable = true; diff --git a/src/nixos/displaymanager.nix b/src/nixos/displaymanager.nix index 4137183..e42d873 100644 --- a/src/nixos/displaymanager.nix +++ b/src/nixos/displaymanager.nix @@ -14,10 +14,18 @@ # ''; session = [ { - manage = "desktop"; - name = "xsession"; + manage = "window"; + name = "hm"; start = '' - exec $HOME/.xsession + # export GDK_SCALE=2 + # export GDK_DPI_SCALE=0.5 + # export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2" + # export QT_AUTO_SCREEN_SCALE_FACTOR=1 + # export QT_DEVICE_PIXEL_RATIO=2 + # echo "Xft.dpi: 192" | xrdb -merge + # export XCURSOR_SIZE=64 + ${pkgs.stdenv.shell} $HOME/.xsession-hm & + waitPID=$! ''; } ];