xdg portal+other minor changes

This commit is contained in:
chayleaf 2023-01-25 01:33:07 +07:00
parent 2e02d83abe
commit c60ba65be0
7 changed files with 82 additions and 34 deletions

View file

@ -1,5 +1,26 @@
{ config, pkgs, lib, ... }: { 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 # TODO sort out this mess with colors
programs.mpv = { programs.mpv = {
enable = true; enable = true;

View file

@ -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'"; 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"; terminal = if config.useAlacritty then "${pkgs.alacritty}/bin/alacritty" else "${pkgs.urxvt}/bin/urxvt";
window = { window.hideEdgeBorders = "smart";
hideEdgeBorders = "smart";
};
workspaceAutoBackAndForth = true; workspaceAutoBackAndForth = true;
floating.criteria = [
{ title = "Steam - Update News"; }
];
}; };
genKeybindings = (default_options: kb: genKeybindings = (default_options: kb:
kb // { kb // {
@ -124,14 +119,36 @@ genKeybindings = (default_options: kb:
); );
in in
{ {
# TODO merge with colors in gui.nix
imports = [ ./options.nix ./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 = { programs.mako = {
enable = lib.mkDefault config.wayland.windowManager.sway.enable; enable = lib.mkDefault config.wayland.windowManager.sway.enable;
# ms # ms
defaultTimeout = 7500; defaultTimeout = 7500;
font = "Noto Sans Mono 12"; font = "Noto Sans Mono 12";
}; };
# TODO merge with colors in gui.nix
programs.alacritty = { programs.alacritty = {
enable = lib.mkDefault config.useAlacritty; enable = lib.mkDefault config.useAlacritty;
settings = { settings = {
@ -177,9 +194,9 @@ in
fonts = [ "xft:Noto Sans Mono:pixelsize=16" "xft:Symbols Nerd Font Mono:pixelsize=16" ]; fonts = [ "xft:Noto Sans Mono:pixelsize=16" "xft:Symbols Nerd Font Mono:pixelsize=16" ];
}; };
xsession.windowManager.i3 = { xsession.windowManager.i3 = {
config = { config = let i3Config = {
keybindings = genKeybindings options.xsession.windowManager.i3 {}; keybindings = genKeybindings options.xsession.windowManager.i3 {};
} // commonConfig; }; in i3Config // commonConfig // i3Config;
}; };
home.file.".xinitrc".text = '' home.file.".xinitrc".text = ''
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
@ -192,22 +209,24 @@ in
exec i3 exec i3
''; '';
xsession.initExtra = '' 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 setxkbmap -layout jp,ru -option caps:swapescape,compose:menu,grp:win_space_toggle
''; '';
home.packages = with pkgs; if config.wayland.windowManager.sway.enable then [ home.packages = with pkgs; if config.wayland.windowManager.sway.enable then [
wl-clipboard wl-clipboard
xdg-desktop-portal
xdg-desktop-portal-wlr
xdg-desktop-portal-gtk
] else []; ] else [];
wayland.windowManager.sway = { wayland.windowManager.sway = {
wrapperFeatures.gtk = true; 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 = { assigns = {
"3" = [{ app_id = "org.keepassxc.KeePassXC"; }]; "3" = [{ app_id = "org.keepassxc.KeePassXC"; }];
}; };
@ -216,6 +235,10 @@ in
"${modifier}+Mod1+Print" = "exec ${grimshot}/bin/grimshot copy window"; "${modifier}+Mod1+Print" = "exec ${grimshot}/bin/grimshot copy window";
}); });
startup = [ startup = [
{
always = true;
command = "systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP";
}
{ {
command = "~/scripts/initwm.sh"; command = "~/scripts/initwm.sh";
} }
@ -237,23 +260,17 @@ in
xkb_options = "caps:swapescape,compose:menu,grp:win_space_toggle"; xkb_options = "caps:swapescape,compose:menu,grp:win_space_toggle";
}; };
}; };
} // commonConfig; }; in swayConfig // commonConfig // swayConfig;
extraSessionCommands = '' 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 BEMENU_BACKEND=wayland
export SDL_VIDEODRIVER=wayland export SDL_VIDEODRIVER=wayland
export QT_QPA_PLATFORM=wayland export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export QT_QPA_PLATFORMTHEME=gnome export QT_QPA_PLATFORMTHEME=gnome
export MOZ_ENABLE_WAYLAND=1 export MOZ_ENABLE_WAYLAND=1
export GDK_BACKEND=wayland
export GTK_USE_PORTAL=1
export XDG_CURRENT_DESKTOP=sway
''; '';
}; };
} }

View file

@ -39,7 +39,7 @@ in {
''; '';
plugins = with pkgs.kakounePlugins; [ kak-lsp sleuth-kak tabs-kak ]; 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 # bash, clangd, json, html, css, python work out of the box
[language.rust] [language.rust]
filetypes = ["rust"] filetypes = ["rust"]

View file

@ -6,15 +6,19 @@ use swayipc_async::{Connection, Event, EventType, WindowChange};
#[tokio::main(flavor = "current_thread")] #[tokio::main(flavor = "current_thread")]
async fn main() { async fn main() {
let (dbus, _server_handle) = DBus::system(false, false) let (sys_dbus, _server_handle) = DBus::system(false, false)
.await .await
.expect("failed to get the DBus object"); .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::<Box<dyn SwayIpcHandler>>::new(); let mut handlers = Vec::<Box<dyn SwayIpcHandler>>::new();
for args in std::env::args().skip(1) { for args in std::env::args().skip(1) {
handlers.push(match args.as_str() { 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"), _ => panic!("handler not supported"),
}) })
} }
@ -85,3 +89,4 @@ impl SwayIpcHandler for System76 {
} }
} }
} }

View file

@ -45,7 +45,7 @@
cmakeFlags = old.cmakeFlags ++ [ "-DENABLE_PULSEAUDIO=no" ]; cmakeFlags = old.cmakeFlags ++ [ "-DENABLE_PULSEAUDIO=no" ];
})) }))
]; ];
home.file."${config.xdg.configHome}/looking-glass/client.ini".text = '' xdg.configFile."looking-glass/client.ini".text = ''
[app] [app]
shmFile=/dev/kvmfr0 shmFile=/dev/kvmfr0
capture=dxgi capture=dxgi

View file

@ -11,7 +11,7 @@
let let
hw = nixos-hardware.nixosModules; hw = nixos-hardware.nixosModules;
# IRL-related stuff I'd rather not put into git # 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 {}); getPriv = (hostname: with builtins; if hasAttr hostname priv then getAttr hostname priv else {});
in utils.lib.mkFlake { in utils.lib.mkFlake {
inherit self inputs; inherit self inputs;

View file

@ -131,6 +131,11 @@ in {
jack.enable = true; jack.enable = true;
}; };
xdg.portal = {
enable = true;
extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ];
};
users.users.user = { users.users.user = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "networkmanager" "wheel" ]; extraGroups = [ "networkmanager" "wheel" ];