From c60ba65be070c8e495734d063fc90fc33005b7fb Mon Sep 17 00:00:00 2001 From: chayleaf Date: Wed, 25 Jan 2023 01:33:07 +0700 Subject: [PATCH] xdg portal+other minor changes --- home/common/gui.nix | 21 +++++++++++ home/common/i3-sway.nix | 73 ++++++++++++++++++++++-------------- home/common/kakoune.nix | 2 +- home/home-daemon/src/main.rs | 11 ++++-- home/hosts/nixmsi.nix | 2 +- system/flake.nix | 2 +- system/hosts/nixmsi.nix | 5 +++ 7 files changed, 82 insertions(+), 34 deletions(-) diff --git a/home/common/gui.nix b/home/common/gui.nix index ef6e5ae..e301ea3 100644 --- a/home/common/gui.nix +++ b/home/common/gui.nix @@ -1,5 +1,26 @@ { config, pkgs, lib, ... }: { + home.sessionVariables."ALSOFT_CONF" = "${config.xdg.configHome}/.config/alsoft.conf"; + xdg.configFile."alsoft.conf".text = '' + [general] + hrtf = true + stereo-encoding = hrtf + drivers = pipewire,pulseaudio,jack,alsa,oss, + periods = 2 + hrtf-paths = ${pkgs.openal}/share/openal/hrtf + + [decoder] + hq-mode = true + + [pipewire] + rt-mix = true + + [pulse] + allow-moves = true + ''; + + xdg.userDirs.enable = true; + # TODO sort out this mess with colors programs.mpv = { enable = true; diff --git a/home/common/i3-sway.nix b/home/common/i3-sway.nix index 4774193..12be2fd 100644 --- a/home/common/i3-sway.nix +++ b/home/common/i3-sway.nix @@ -98,13 +98,8 @@ commonConfig = { }; menu = "${pkgs.bemenu}/bin/bemenu-run --no-overlap --prompt '>' --tb '#24101a' --tf '#ebbe5f' --fb '#24101a' --nb '#24101a70' --ab '#24101a70' --nf '#ebdadd' --af '#ebdadd' --hb '#394893' --hf '#e66e6e' --list 30 --prefix '*' --scrollbar autohide --fn 'Noto Sans Mono' --line-height 23 --sb '#394893' --sf '#ebdadd' --scb '#6b4d52' --scf '#e66e6e'"; terminal = if config.useAlacritty then "${pkgs.alacritty}/bin/alacritty" else "${pkgs.urxvt}/bin/urxvt"; - window = { - hideEdgeBorders = "smart"; - }; + window.hideEdgeBorders = "smart"; workspaceAutoBackAndForth = true; - floating.criteria = [ - { title = "Steam - Update News"; } - ]; }; genKeybindings = (default_options: kb: kb // { @@ -124,14 +119,36 @@ genKeybindings = (default_options: kb: ); in { + # TODO merge with colors in gui.nix imports = [ ./options.nix ./gui.nix ]; + home.sessionVariables = { + BEMENU_OPTS = "--no-overlap --prompt '>' --tb '#24101a' --tf '#ebbe5f' --fb '#24101a' --nb '#24101a70' --ab '#24101a70' --nf '#ebdadd' --af '#ebdadd' --hb '#394893' --hf '#e66e6e' --list 30 --prefix '*' --scrollbar autohide --fn 'Noto Sans Mono' --line-height 23 --sb '#394893' --sf '#ebdadd' --scb '#6b4d52' --scf '#e66e6e'"; + _JAVA_AWT_WM_NONREPARENTING = "1"; + GTK_IM_MODULE = "fcitx"; + QT_IM_MODULE = "fcitx"; + XMODIFIERS = "@im=fcitx"; + SDL_IM_MODULE = "fcitx"; + XIM_SERVERS = "fcitx"; + INPUT_METHOD = "fcitx"; + }; + xdg.configFile."xdg-desktop-portal-wlr/config".source = (pkgs.formats.ini {}).generate "xdg-desktop-portal-wlr.ini" { + screencast = { + max_fps = 60; + chooser_type = "simple"; + chooser-cmd = "''${pkgs.slurp}/bin/slurp -f %o -or"; + # exec_before + # exec_after + }; + }; + systemd.user.services = lib.mkIf config.wayland.windowManager.sway.enable { + gammastep.Unit.ConditionEnvironment = "WAYLAND_DISPLAY"; + }; programs.mako = { enable = lib.mkDefault config.wayland.windowManager.sway.enable; # ms defaultTimeout = 7500; font = "Noto Sans Mono 12"; }; - # TODO merge with colors in gui.nix programs.alacritty = { enable = lib.mkDefault config.useAlacritty; settings = { @@ -177,9 +194,9 @@ in fonts = [ "xft:Noto Sans Mono:pixelsize=16" "xft:Symbols Nerd Font Mono:pixelsize=16" ]; }; xsession.windowManager.i3 = { - config = { + config = let i3Config = { keybindings = genKeybindings options.xsession.windowManager.i3 {}; - } // commonConfig; + }; in i3Config // commonConfig // i3Config; }; home.file.".xinitrc".text = '' if test -z "$DBUS_SESSION_BUS_ADDRESS"; then @@ -192,22 +209,24 @@ in exec i3 ''; xsession.initExtra = '' - export BEMENU_OPTS="--no-overlap --prompt '>' --tb '#24101a' --tf '#ebbe5f' --fb '#24101a' --nb '#24101a70' --ab '#24101a70' --nf '#ebdadd' --af '#ebdadd' --hb '#394893' --hf '#e66e6e' --list 30 --prefix '*' --scrollbar autohide --fn 'Noto Sans Mono' --line-height 23 --sb '#394893' --sf '#ebdadd' --scb '#6b4d52' --scf '#e66e6e'" - export _JAVA_AWT_WM_NONREPARENTING=1 - export GTK_IM_MODULE=fcitx - export QT_IM_MODULE=fcitx - export XMODIFIERS=@im=fcitx - export SDL_IM_MODULE=fcitx - export XIM_SERVERS=fcitx - export INPUT_METHOD=fcitx setxkbmap -layout jp,ru -option caps:swapescape,compose:menu,grp:win_space_toggle ''; home.packages = with pkgs; if config.wayland.windowManager.sway.enable then [ wl-clipboard + xdg-desktop-portal + xdg-desktop-portal-wlr + xdg-desktop-portal-gtk ] else []; wayland.windowManager.sway = { wrapperFeatures.gtk = true; - config = { + config = let swayConfig = { + window.commands = [ + { command = "floating enable; move workspace current"; + criteria = { + app_id = "^org.keepassxc.KeePassXC$"; + title = "^KeePassXC - (?:Browser |ブラウザーの)?(?:Access Request|アクセス要求)$"; + }; } + ]; assigns = { "3" = [{ app_id = "org.keepassxc.KeePassXC"; }]; }; @@ -216,6 +235,10 @@ in "${modifier}+Mod1+Print" = "exec ${grimshot}/bin/grimshot copy window"; }); startup = [ + { + always = true; + command = "systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP"; + } { command = "~/scripts/initwm.sh"; } @@ -237,23 +260,17 @@ in xkb_options = "caps:swapescape,compose:menu,grp:win_space_toggle"; }; }; - } // commonConfig; + }; in swayConfig // commonConfig // swayConfig; extraSessionCommands = '' - export BEMENU_OPTS="--no-overlap --prompt '>' --tb '#24101a' --tf '#ebbe5f' --fb '#24101a' --nb '#24101a70' --ab '#24101a70' --nf '#ebdadd' --af '#ebdadd' --hb '#394893' --hf '#e66e6e' --list 30 --prefix '*' --scrollbar autohide --fn 'Noto Sans Mono' --line-height 23 --sb '#394893' --sf '#ebdadd' --scb '#6b4d52' --scf '#e66e6e'" - export _JAVA_AWT_WM_NONREPARENTING=1 - export GTK_IM_MODULE=fcitx - export QT_IM_MODULE=fcitx - export XMODIFIERS=@im=fcitx - export SDL_IM_MODULE=fcitx - export XIM_SERVERS=fcitx - export INPUT_METHOD=fcitx - export BEMENU_BACKEND=wayland export SDL_VIDEODRIVER=wayland export QT_QPA_PLATFORM=wayland export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 export QT_QPA_PLATFORMTHEME=gnome export MOZ_ENABLE_WAYLAND=1 + export GDK_BACKEND=wayland + export GTK_USE_PORTAL=1 + export XDG_CURRENT_DESKTOP=sway ''; }; } diff --git a/home/common/kakoune.nix b/home/common/kakoune.nix index 2564bd0..cd4e878 100644 --- a/home/common/kakoune.nix +++ b/home/common/kakoune.nix @@ -39,7 +39,7 @@ in { ''; plugins = with pkgs.kakounePlugins; [ kak-lsp sleuth-kak tabs-kak ]; }; - home.file."${config.xdg.configHome}/kak-lsp/kak-lsp.toml".text = '' + xdg.configFile."kak-lsp/kak-lsp.toml".text = '' # bash, clangd, json, html, css, python work out of the box [language.rust] filetypes = ["rust"] diff --git a/home/home-daemon/src/main.rs b/home/home-daemon/src/main.rs index 45ef75d..168410b 100644 --- a/home/home-daemon/src/main.rs +++ b/home/home-daemon/src/main.rs @@ -6,15 +6,19 @@ use swayipc_async::{Connection, Event, EventType, WindowChange}; #[tokio::main(flavor = "current_thread")] async fn main() { - let (dbus, _server_handle) = DBus::system(false, false) + let (sys_dbus, _server_handle) = DBus::system(false, false) .await .expect("failed to get the DBus object"); - let dbus = Arc::new(dbus); + let (ses_dbus, _server_handle) = DBus::session(false, false) + .await + .expect("failed to get the DBus object"); + let sys_dbus = Arc::new(sys_dbus); + let _ses_dbus = Arc::new(ses_dbus); let mut handlers = Vec::>::new(); for args in std::env::args().skip(1) { handlers.push(match args.as_str() { - "system76-scheduler" => Box::new(System76::new(dbus.clone())), + "system76-scheduler" => Box::new(System76::new(sys_dbus.clone())), _ => panic!("handler not supported"), }) } @@ -85,3 +89,4 @@ impl SwayIpcHandler for System76 { } } } + diff --git a/home/hosts/nixmsi.nix b/home/hosts/nixmsi.nix index 8290545..f4dba54 100644 --- a/home/hosts/nixmsi.nix +++ b/home/hosts/nixmsi.nix @@ -45,7 +45,7 @@ cmakeFlags = old.cmakeFlags ++ [ "-DENABLE_PULSEAUDIO=no" ]; })) ]; - home.file."${config.xdg.configHome}/looking-glass/client.ini".text = '' + xdg.configFile."looking-glass/client.ini".text = '' [app] shmFile=/dev/kvmfr0 capture=dxgi diff --git a/system/flake.nix b/system/flake.nix index 4839648..809d397 100644 --- a/system/flake.nix +++ b/system/flake.nix @@ -11,7 +11,7 @@ let hw = nixos-hardware.nixosModules; # IRL-related stuff I'd rather not put into git - priv = if builtins.fileExists ./private.nix then (import ./private.nix inputs) else {}; + priv = if builtins.pathExists ./private.nix then (import ./private.nix) else {}; getPriv = (hostname: with builtins; if hasAttr hostname priv then getAttr hostname priv else {}); in utils.lib.mkFlake { inherit self inputs; diff --git a/system/hosts/nixmsi.nix b/system/hosts/nixmsi.nix index f92758d..ee3892c 100644 --- a/system/hosts/nixmsi.nix +++ b/system/hosts/nixmsi.nix @@ -131,6 +131,11 @@ in { jack.enable = true; }; + xdg.portal = { + enable = true; + extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ]; + }; + users.users.user = { isNormalUser = true; extraGroups = [ "networkmanager" "wheel" ];