sway: Manually implement systemd/dbus integration
The way provided by home-manager does not work reliably. This also references (hopefully) all executables called by systemd services by their full path.
This commit is contained in:
parent
84c72583fe
commit
09618443eb
|
@ -28,7 +28,6 @@ in
|
|||
lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
systemdIntegration = true;
|
||||
|
||||
# TODO: remove with 21.05
|
||||
package = pkgs.unstable.sway;
|
||||
|
@ -208,10 +207,23 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
extraConfig = ''
|
||||
# Cursor
|
||||
seat seat0 xcursor_theme Adwaita
|
||||
|
||||
# GCR prompter requires dbus to have wayland related variables
|
||||
exec "dbus-update-activation-environment WAYLAND_DISPLAY"
|
||||
'';
|
||||
'' + (
|
||||
let
|
||||
environmentVariables = lib.concatStringsSep " " [
|
||||
"DBUS_SESSION_BUS_ADDRESS"
|
||||
"DISPLAY"
|
||||
"SWAYSOCK"
|
||||
"WAYLAND_DISPLAY"
|
||||
];
|
||||
in
|
||||
''
|
||||
# From https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start
|
||||
exec systemctl --user import-environment ${environmentVariables} && \
|
||||
hash dbus-update-activation-environment 2>/dev/null && \
|
||||
dbus-update-activation-environment --systemd ${environmentVariables} && \
|
||||
systemctl --user start sway-session.target
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
home.sessionVariables = {
|
||||
|
@ -227,11 +239,23 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
_JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=on";
|
||||
};
|
||||
|
||||
systemd.user.targets.sway-session = {
|
||||
Unit = {
|
||||
Description = "sway compositor session";
|
||||
Documentation = [ "man:systemd.special(7)" ];
|
||||
BindsTo = [ "graphical-session.target" ];
|
||||
Wants = [ "graphical-session-pre.target" ];
|
||||
After = [ "graphical-session-pre.target" ];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.swayidle = {
|
||||
Unit.PartOf = [ "sway-session.target" ];
|
||||
Install.WantedBy = [ "sway-session.target" ];
|
||||
|
||||
Service = {
|
||||
# swayidle requires sh and swaymsg to be in path
|
||||
Environment = "PATH=${pkgs.bash}/bin:${config.wayland.windowManager.sway.package}/bin";
|
||||
ExecStart = ''
|
||||
${pkgs.swayidle}/bin/swayidle -w \
|
||||
timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \
|
||||
|
@ -366,7 +390,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
set -euo pipefail
|
||||
(echo; ${pkgs.inotify-tools}/bin/inotifywait -m -e close_write ${lib.escapeShellArg makoInhibitStateFile} 2>/dev/null) \
|
||||
| (while read line; do
|
||||
if [ "$(cat ${lib.escapeShellArg makoInhibitStateFile})" = "1" ]; then
|
||||
if [ "$(${pkgs.coreutils}/bin/cat ${lib.escapeShellArg makoInhibitStateFile})" = "1" ]; then
|
||||
echo '{"alt": "active", "class": "active"}'
|
||||
else
|
||||
echo '{"alt": "inactive", "class": "inactive"}'
|
||||
|
@ -382,7 +406,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
tooltip = false;
|
||||
on-click = pkgs.writeShellScript "toggle-notification-inhibit" ''
|
||||
set -e
|
||||
current_state="$(cat ${lib.escapeShellArg makoInhibitStateFile})"
|
||||
current_state="$(${pkgs.coreutils}/bin/cat ${lib.escapeShellArg makoInhibitStateFile})"
|
||||
if [ "$current_state" = "0" ]; then
|
||||
${pkgs.mako}/bin/makoctl set invisible=true
|
||||
echo 1 > ${lib.escapeShellArg makoInhibitStateFile}
|
||||
|
@ -395,11 +419,11 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
backlight = {
|
||||
format = "{percent}% {icon}";
|
||||
format-icons = [ " " " " " " " " " " " " " " ];
|
||||
on-scroll-up = "brightnessctl set +5%";
|
||||
on-scroll-down = "brightnessctl set 5%-";
|
||||
on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl -q set +5%";
|
||||
on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl -q set 5%-";
|
||||
};
|
||||
mpd = {
|
||||
server = "${config.services.mpd.dataDir}/socket";
|
||||
server = config.services.mpd.network.listenAddress;
|
||||
format = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} – {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ";
|
||||
format-disconnected = "Disconnected ";
|
||||
format-stopped = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ";
|
||||
|
@ -407,8 +431,8 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
interval = 2;
|
||||
tooltip-format = "MPD (connected)";
|
||||
tooltip-format-disconnected = "MPD (disconnected)";
|
||||
on-scroll-up = "${pkgs.mpc_cli}/bin/mpc -q volume +2";
|
||||
on-scroll-down = "${pkgs.mpc_cli}/bin/mpc -q volume -2";
|
||||
on-scroll-up = "${pkgs.mpc_cli}/bin/mpc -q -h ${config.services.mpd.network.listenAddress} volume +2";
|
||||
on-scroll-down = "${pkgs.mpc_cli}/bin/mpc -q -h ${config.services.mpd.network.listenAddress} volume -2";
|
||||
consume-icons = {
|
||||
on = " ";
|
||||
};
|
||||
|
@ -443,7 +467,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
phone = " ";
|
||||
portable = " ";
|
||||
};
|
||||
on-click-right = "pavucontrol";
|
||||
on-click-right = "${pkgs.pavucontrol}/bin/pavucontrol";
|
||||
};
|
||||
network = {
|
||||
format-wifi = "{essid} ({signalStrength}%) 直 ";
|
||||
|
@ -452,13 +476,13 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
format-disconnected = "Disconnected ⚠ ";
|
||||
format-alt = "{ifname}: {ipaddr}/{cidr}";
|
||||
tooltip = false;
|
||||
on-click-right = "alacritty -e nmtui";
|
||||
on-click-right = "${config.programs.alacritty.package}/bin/alacritty -e ${pkgs.networkmanager}/bin/nmtui";
|
||||
};
|
||||
"custom/vpn" = {
|
||||
interval = 10;
|
||||
exec = pkgs.writeShellScript "vpn-state" ''
|
||||
ip -j link \
|
||||
| jq --unbuffered --compact-output '
|
||||
${pkgs.iproute}/bin/ip -j link \
|
||||
| ${pkgs.jq}/bin/jq --unbuffered --compact-output '
|
||||
[[.[].ifname | select(. | startswith("mullvad"))][] | split("-")[1] + " ${thinsp}"] as $conns
|
||||
| { text: ($conns[0] // ""), class: (if $conns | length > 0 then "connected" else "disconnected" end) }'
|
||||
'';
|
||||
|
@ -550,7 +574,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
|||
Service = {
|
||||
ExecStartPre = toString (pkgs.writeShellScript "reset-mako-inhibit-state" ''
|
||||
set -e
|
||||
mkdir -p "$(dirname ${lib.escapeShellArg makoInhibitStateFile})"
|
||||
${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname ${lib.escapeShellArg makoInhibitStateFile})"
|
||||
echo 0 > ${lib.escapeShellArg makoInhibitStateFile}
|
||||
'');
|
||||
ExecStart = "${pkgs.mako}/bin/mako";
|
||||
|
|
Loading…
Reference in a new issue