Rework how X session is started
This commit is contained in:
parent
41c3266ee2
commit
8a4875cf5b
|
@ -1,20 +1,35 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
nixgl = import
|
||||||
|
(builtins.fetchGit {
|
||||||
|
url = "https://github.com/nix-community/nixGL";
|
||||||
|
rev = "489d6b095ab9d289fe11af0219a9ff00fe87c7c5";
|
||||||
|
})
|
||||||
|
{ };
|
||||||
|
nixGLIntelPrefix = "${nixgl.nixVulkanIntel}/bin/nixVulkanIntel ${nixgl.nixGLIntel}/bin/nixGLIntel ";
|
||||||
|
wmPrefix = "${lib.optionalString config.frogeye.desktop.nixGLIntel nixGLIntelPrefix}";
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
./frobar
|
||||||
|
];
|
||||||
config = lib.mkIf config.frogeye.desktop.xorg {
|
config = lib.mkIf config.frogeye.desktop.xorg {
|
||||||
frogeye.shellAliases = {
|
frogeye.shellAliases = {
|
||||||
noise = ''${pkgs.sox}/bin/play -c 2 -n synth $'' + ''{1}noise'';
|
noise = ''${pkgs.sox}/bin/play -c 2 -n synth $'' + ''{1}noise'';
|
||||||
beep = ''${pkgs.sox}/bin/play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null'';
|
beep = ''${pkgs.sox}/bin/play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null'';
|
||||||
|
|
||||||
# n = "$HOME/.config/i3/terminal & disown"; # Not used anymore since alacritty daemon mode doesn't preserve environment variables
|
# n = "$HOME/.config/i3/terminal & disown"; # Not used anymore since alacritty daemon mode doesn't preserve environment variables
|
||||||
x = "startx ${config.xdg.configHome}/xinitrc; logout";
|
x = "startx ${config.home.homeDirectory}/${config.xsession.scriptPath}; logout";
|
||||||
nx = "nvidia-xrun ${config.xdg.configHome}/xinitrc; sudo systemctl start nvidia-xrun-pm; logout";
|
# TODO Is it possible to not start nvidia stuff on nixOS?
|
||||||
# Was also thinking of not storing the config in .config and use nix-store instead,
|
# nx = "nvidia-xrun ${config.xsession.scriptPath}; sudo systemctl start nvidia-xrun-pm; logout";
|
||||||
# but maybe it's a bad idea as home-manager switch doesn't replace aliases in running shells
|
|
||||||
# FIXME Is it still relevant with NixOS?
|
|
||||||
};
|
};
|
||||||
xsession = {
|
xsession = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
# Not using config.xdg.configHome because it needs to be $HOME-relative paths and path manipulation is hard
|
||||||
|
scriptPath = ".config/xsession";
|
||||||
|
profilePath = ".config/xprofile";
|
||||||
windowManager = {
|
windowManager = {
|
||||||
|
command = lib.mkForce "${wmPrefix} ${config.xsession.windowManager.i3.package}/bin/i3";
|
||||||
i3 = {
|
i3 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
config =
|
config =
|
||||||
|
@ -68,7 +83,6 @@
|
||||||
{
|
{
|
||||||
modifier = "Mod4";
|
modifier = "Mod4";
|
||||||
terminal = "alacritty";
|
terminal = "alacritty";
|
||||||
bars = [ ]; # Using frobar
|
|
||||||
colors = let ignore = "#ff00ff"; in
|
colors = let ignore = "#ff00ff"; in
|
||||||
with config.lib.stylix.colors.withHashtag; lib.mkForce {
|
with config.lib.stylix.colors.withHashtag; lib.mkForce {
|
||||||
focused = { border = base0B; background = base0B; text = base00; indicator = base00; childBorder = base0B; };
|
focused = { border = base0B; background = base0B; text = base00; indicator = base00; childBorder = base0B; };
|
||||||
|
@ -310,7 +324,6 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
startup = [
|
startup = [
|
||||||
{ notification = false; command = "${pkgs.autorandr}/bin/autorandr --change"; }
|
|
||||||
# Lock screen after 10 minutes
|
# Lock screen after 10 minutes
|
||||||
{ notification = false; command = "${pkgs.xautolock}/bin/xautolock -time 10 -locker '${pkgs.xorg.xset}/bin/xset dpms force standby' -killtime 1 -killer ${locker}"; }
|
{ notification = false; command = "${pkgs.xautolock}/bin/xautolock -time 10 -locker '${pkgs.xorg.xset}/bin/xset dpms force standby' -killtime 1 -killer ${locker}"; }
|
||||||
{
|
{
|
||||||
|
@ -498,14 +511,9 @@
|
||||||
};
|
};
|
||||||
autorandr = {
|
autorandr = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hooks.postswitch =
|
hooks.postswitch = {
|
||||||
let
|
background = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}";
|
||||||
frobar = (pkgs.callPackage (import ./frobar) { });
|
};
|
||||||
in
|
|
||||||
{
|
|
||||||
"background" = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}";
|
|
||||||
"frobar" = "${pkgs.i3}/bin/i3-msg exec ${frobar}/bin/frobar_launcher";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
mpv = {
|
mpv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -553,23 +561,6 @@
|
||||||
"pulse/client.conf" = {
|
"pulse/client.conf" = {
|
||||||
text = ''cookie-file = .config/pulse/pulse-cookie'';
|
text = ''cookie-file = .config/pulse/pulse-cookie'';
|
||||||
};
|
};
|
||||||
"xinitrc" =
|
|
||||||
let
|
|
||||||
nixgl = import
|
|
||||||
(builtins.fetchGit {
|
|
||||||
url = "https://github.com/nix-community/nixGL";
|
|
||||||
rev = "489d6b095ab9d289fe11af0219a9ff00fe87c7c5";
|
|
||||||
})
|
|
||||||
{ };
|
|
||||||
nixGLIntelPrefix = "${nixgl.nixVulkanIntel}/bin/nixVulkanIntel ${nixgl.nixGLIntel}/bin/nixGLIntel ";
|
|
||||||
wmPrefix = "${lib.optionalString config.frogeye.desktop.nixGLIntel nixGLIntelPrefix}";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
source = pkgs.writeShellScript "xinitrc" ''
|
|
||||||
${pkgs.xorg.xrdb}/bin/xrdb ${config.xresources.path}
|
|
||||||
${wmPrefix}${config.xsession.windowManager.command}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
"rofimoji.rc" = {
|
"rofimoji.rc" = {
|
||||||
text = ''
|
text = ''
|
||||||
skin-tone = neutral
|
skin-tone = neutral
|
||||||
|
@ -593,7 +584,6 @@
|
||||||
};
|
};
|
||||||
services = {
|
services = {
|
||||||
unclutter.enable = true;
|
unclutter.enable = true;
|
||||||
# FIXME Not starting on curacao_test
|
|
||||||
dunst =
|
dunst =
|
||||||
{
|
{
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs ? import <nixpkgs> { config = { }; overlays = [ ]; } }:
|
{ pkgs ? import <nixpkgs> { config = { }; overlays = [ ]; }, ... }:
|
||||||
# Tried using pyproject.nix but mpd2 dependency wouldn't resolve,
|
# Tried using pyproject.nix but mpd2 dependency wouldn't resolve,
|
||||||
# is called pyton-mpd2 on PyPi but mpd2 in nixpkgs.
|
# is called pyton-mpd2 on PyPi but mpd2 in nixpkgs.
|
||||||
let
|
let
|
||||||
|
@ -6,6 +6,7 @@ let
|
||||||
pname = "frobar";
|
pname = "frobar";
|
||||||
version = "2.0";
|
version = "2.0";
|
||||||
|
|
||||||
|
runtimeInputs = with pkgs; [ lemonbar-xft wirelesstools ];
|
||||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||||
coloredlogs
|
coloredlogs
|
||||||
notmuch
|
notmuch
|
||||||
|
@ -15,21 +16,33 @@ let
|
||||||
pulsectl
|
pulsectl
|
||||||
pyinotify
|
pyinotify
|
||||||
];
|
];
|
||||||
|
makeWrapperArgs = [ "--prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ lemonbar-xft wirelesstools ])}" ];
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
};
|
};
|
||||||
frobar_launcher = pkgs.writeShellApplication
|
|
||||||
{
|
|
||||||
name = "frobar_launcher";
|
|
||||||
runtimeInputs = with pkgs; [ lemonbar-xft wirelesstools ];
|
|
||||||
text = ''
|
|
||||||
pidfile=$XDG_RUNTIME_DIR/frobar/$DISPLAY.pid
|
|
||||||
${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname "$pidfile")"
|
|
||||||
([ -f "$pidfile" ] && ${pkgs.procps}/bin/kill "$(<"$pidfile")") || true
|
|
||||||
${frobar}/bin/frobar & disown
|
|
||||||
echo $! > "$pidfile"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
frobar_launcher
|
{
|
||||||
# TODO Connection with i3 is lost sometimes, more often than with Arch?
|
config = {
|
||||||
|
xsession.windowManager.i3.config.bars = [ ];
|
||||||
|
programs.autorandr.hooks.postswitch = {
|
||||||
|
frobar = "${pkgs.systemd}/bin/systemctl --user restart frobar";
|
||||||
|
};
|
||||||
|
systemd.user.services.frobar = {
|
||||||
|
Unit = {
|
||||||
|
Description = "frobar";
|
||||||
|
After = [ "graphical-session-pre.target" ];
|
||||||
|
PartOf = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
# Wait for i3 to start. Can't use ExecStartPre because otherwise it blocks graphical-session.target, and there's nothing i3/systemd
|
||||||
|
# TODO Do that better
|
||||||
|
ExecStart = ''${pkgs.bash}/bin/bash -c "while ! ${pkgs.i3}/bin/i3-msg; do ${pkgs.coreutils}/bin/sleep 1; done; ${frobar}/bin/frobar"'';
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
# TODO Connection with i3 is lost on start sometimes, more often than with Arch?
|
||||||
|
# TODO Restore ability to build frobar with nix-build
|
||||||
|
|
Loading…
Reference in a new issue