fix multi DPI scaling in x11 using xsession

This commit is contained in:
Ray Andrew 2024-11-16 23:58:28 -06:00
parent 074117be1e
commit ed15864d22
9 changed files with 66 additions and 19 deletions

View file

@ -2,6 +2,7 @@
lib, lib,
pkgs, pkgs,
config, config,
wallpaper,
... ...
}: }:
{ {
@ -117,7 +118,7 @@
toggle-stacking-global = [ "<Super>s" ]; toggle-stacking-global = [ "<Super>s" ];
}; };
"org/gnome/desktop/background" = { "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" = { "org/gnome/desktop/interface" = {
color-scheme = "prefer-dark"; color-scheme = "prefer-dark";

View file

@ -7,9 +7,9 @@
{ {
programs.bash.enable = true; programs.bash.enable = true;
programs.bash.enableVteIntegration = true; programs.bash.enableVteIntegration = true;
programs.bash.initExtra = lib.mkAfter '' # programs.bash.initExtra = lib.mkAfter ''
export NIX_LD=$(nix eval --impure --raw --expr 'let pkgs = import <nixpkgs> {}; NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; in NIX_LD') # export NIX_LD=$(nix eval --impure --raw --expr 'let pkgs = import <nixpkgs> {}; NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; in NIX_LD')
''; # '';
programs.bash.bashrcExtra = lib.mkAfter '' programs.bash.bashrcExtra = lib.mkAfter ''
if [ "$term" != "dumb" ] || [ -n "$inside_emacs" ]; then if [ "$term" != "dumb" ] || [ -n "$inside_emacs" ]; then
prompt_color="1;32m" prompt_color="1;32m"

View file

@ -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 = { ui = {
-- If you are using a Nerd Font: set icons to an empty table which will use the -- If you are using a Nerd Font: set icons to an empty table which will use the

View file

@ -19,6 +19,7 @@
"multicursor.nvim": { "branch": "1.0", "commit": "b715cc5bf69cf6e338899510eb2b60b1dd7ccce0" }, "multicursor.nvim": { "branch": "1.0", "commit": "b715cc5bf69cf6e338899510eb2b60b1dd7ccce0" },
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
"nvim-lspconfig": { "branch": "master", "commit": "87c7c83ce62971e0bdb29bb32b8ad2b19c8f95d0" }, "nvim-lspconfig": { "branch": "master", "commit": "87c7c83ce62971e0bdb29bb32b8ad2b19c8f95d0" },
"nvim-osc52": { "branch": "main", "commit": "04cfaba1865ae5c53b6f887c3ca7304973824fb2" },
"nvim-treesitter": { "branch": "master", "commit": "20e10ca6914f65cf1410232433fb58de70ab6b39" }, "nvim-treesitter": { "branch": "master", "commit": "20e10ca6914f65cf1410232433fb58de70ab6b39" },
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
"oil.nvim": { "branch": "master", "commit": "8ea40b5506115b6d355e304dd9ee5089f7d78601" }, "oil.nvim": { "branch": "master", "commit": "8ea40b5506115b6d355e304dd9ee5089f7d78601" },

View file

@ -6,6 +6,9 @@ _: {
]; ];
config = { config = {
xsession.enable = true; xsession = {
enable = true;
scriptPath = ".xsession-hm";
};
}; };
} }

View file

@ -2,6 +2,7 @@
pkgs, pkgs,
lib, lib,
config, config,
wallpaper,
... ...
}: }:
let let
@ -30,9 +31,11 @@ in
}; };
config = lib.mkIf config.custom.wm.i3.enable { config = lib.mkIf config.custom.wm.i3.enable {
home.packages = with pkgs; [ home.packages = with pkgs; [
arandr arandr
feh
xfce.xfce4-volumed-pulse
autorandr
]; ];
services.picom = { services.picom = {
enable = true; enable = true;
@ -40,15 +43,15 @@ in
services.dunst = { services.dunst = {
enable = true; enable = true;
}; };
# xsession.profileExtra = '' xsession.initExtra = ''
# export GDK_SCALE=2 export GDK_SCALE=2
# export GDK_DPI_SCALE=0.5 export GDK_DPI_SCALE=0.5
# export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2" export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2"
# export QT_AUTO_SCREEN_SCALE_FACTOR=1 export QT_AUTO_SCREEN_SCALE_FACTOR=1
# export QT_DEVICE_PIXEL_RATIO=2 export QT_DEVICE_PIXEL_RATIO=2
# echo "Xft.dpi: 192" | xrdb -merge echo "Xft.dpi: 192" | xrdb -merge
# export XCURSOR_SIZE=64 export XCURSOR_SIZE=64
# ''; '';
xsession.windowManager.i3 = { xsession.windowManager.i3 = {
enable = true; enable = true;
extraConfig = commonOptions.extraConfig; 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"; "${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"; "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;
}
];
} }
]; ];
}; };

View file

@ -40,6 +40,7 @@ let
extraSpecialArgs = specialArgs // { extraSpecialArgs = specialArgs // {
inherit host user; inherit host user;
dots = "/home/${user}/code/nix-config"; dots = "/home/${user}/code/nix-config";
wallpaper = pkgs.nixos-artwork.wallpapers.nineish-dark-gray.src;
}; };
users.${user} = { users.${user} = {

View file

@ -47,7 +47,7 @@
bluetooth.enable = true; bluetooth.enable = true;
wm = { wm = {
i3.enable = true; i3.enable = true;
sway.enable = true; sway.enable = false;
}; };
gnome = { gnome = {
enable = true; enable = true;

View file

@ -14,10 +14,18 @@
# ''; # '';
session = [ session = [
{ {
manage = "desktop"; manage = "window";
name = "xsession"; name = "hm";
start = '' 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=$!
''; '';
} }
]; ];