Rework how X session is started
This commit is contained in:
parent
41c3266ee2
commit
8a4875cf5b
2 changed files with 51 additions and 48 deletions
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> { config = { }; overlays = [ ]; } }:
|
||||
{ pkgs ? import <nixpkgs> { config = { }; overlays = [ ]; }, ... }:
|
||||
# Tried using pyproject.nix but mpd2 dependency wouldn't resolve,
|
||||
# is called pyton-mpd2 on PyPi but mpd2 in nixpkgs.
|
||||
let
|
||||
|
@ -6,6 +6,7 @@ let
|
|||
pname = "frobar";
|
||||
version = "2.0";
|
||||
|
||||
runtimeInputs = with pkgs; [ lemonbar-xft wirelesstools ];
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
coloredlogs
|
||||
notmuch
|
||||
|
@ -15,21 +16,33 @@ let
|
|||
pulsectl
|
||||
pyinotify
|
||||
];
|
||||
makeWrapperArgs = [ "--prefix PATH : ${pkgs.lib.makeBinPath (with pkgs; [ lemonbar-xft wirelesstools ])}" ];
|
||||
|
||||
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
|
||||
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…
Add table
Add a link
Reference in a new issue