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 {
|
lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
wayland.windowManager.sway = {
|
wayland.windowManager.sway = {
|
||||||
enable = true;
|
enable = true;
|
||||||
systemdIntegration = true;
|
|
||||||
|
|
||||||
# TODO: remove with 21.05
|
# TODO: remove with 21.05
|
||||||
package = pkgs.unstable.sway;
|
package = pkgs.unstable.sway;
|
||||||
|
@ -208,10 +207,23 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
# Cursor
|
# Cursor
|
||||||
seat seat0 xcursor_theme Adwaita
|
seat seat0 xcursor_theme Adwaita
|
||||||
|
'' + (
|
||||||
# GCR prompter requires dbus to have wayland related variables
|
let
|
||||||
exec "dbus-update-activation-environment WAYLAND_DISPLAY"
|
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 = {
|
home.sessionVariables = {
|
||||||
|
@ -227,11 +239,23 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
_JAVA_OPTIONS = "-Dawt.useSystemAAFontSettings=on";
|
_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 = {
|
systemd.user.services.swayidle = {
|
||||||
Unit.PartOf = [ "sway-session.target" ];
|
Unit.PartOf = [ "sway-session.target" ];
|
||||||
Install.WantedBy = [ "sway-session.target" ];
|
Install.WantedBy = [ "sway-session.target" ];
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
|
# swayidle requires sh and swaymsg to be in path
|
||||||
|
Environment = "PATH=${pkgs.bash}/bin:${config.wayland.windowManager.sway.package}/bin";
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.swayidle}/bin/swayidle -w \
|
${pkgs.swayidle}/bin/swayidle -w \
|
||||||
timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \
|
timeout 300 "${pkgs.swaylock}/bin/swaylock -f -i ${wallpaper}" \
|
||||||
|
@ -366,7 +390,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
(echo; ${pkgs.inotify-tools}/bin/inotifywait -m -e close_write ${lib.escapeShellArg makoInhibitStateFile} 2>/dev/null) \
|
(echo; ${pkgs.inotify-tools}/bin/inotifywait -m -e close_write ${lib.escapeShellArg makoInhibitStateFile} 2>/dev/null) \
|
||||||
| (while read line; do
|
| (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"}'
|
echo '{"alt": "active", "class": "active"}'
|
||||||
else
|
else
|
||||||
echo '{"alt": "inactive", "class": "inactive"}'
|
echo '{"alt": "inactive", "class": "inactive"}'
|
||||||
|
@ -382,7 +406,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
tooltip = false;
|
tooltip = false;
|
||||||
on-click = pkgs.writeShellScript "toggle-notification-inhibit" ''
|
on-click = pkgs.writeShellScript "toggle-notification-inhibit" ''
|
||||||
set -e
|
set -e
|
||||||
current_state="$(cat ${lib.escapeShellArg makoInhibitStateFile})"
|
current_state="$(${pkgs.coreutils}/bin/cat ${lib.escapeShellArg makoInhibitStateFile})"
|
||||||
if [ "$current_state" = "0" ]; then
|
if [ "$current_state" = "0" ]; then
|
||||||
${pkgs.mako}/bin/makoctl set invisible=true
|
${pkgs.mako}/bin/makoctl set invisible=true
|
||||||
echo 1 > ${lib.escapeShellArg makoInhibitStateFile}
|
echo 1 > ${lib.escapeShellArg makoInhibitStateFile}
|
||||||
|
@ -395,11 +419,11 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
backlight = {
|
backlight = {
|
||||||
format = "{percent}% {icon}";
|
format = "{percent}% {icon}";
|
||||||
format-icons = [ " " " " " " " " " " " " " " ];
|
format-icons = [ " " " " " " " " " " " " " " ];
|
||||||
on-scroll-up = "brightnessctl set +5%";
|
on-scroll-up = "${pkgs.brightnessctl}/bin/brightnessctl -q set +5%";
|
||||||
on-scroll-down = "brightnessctl set 5%-";
|
on-scroll-down = "${pkgs.brightnessctl}/bin/brightnessctl -q set 5%-";
|
||||||
};
|
};
|
||||||
mpd = {
|
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 = "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} – {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ";
|
||||||
format-disconnected = "Disconnected ";
|
format-disconnected = "Disconnected ";
|
||||||
format-stopped = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ";
|
format-stopped = "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ";
|
||||||
|
@ -407,8 +431,8 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
interval = 2;
|
interval = 2;
|
||||||
tooltip-format = "MPD (connected)";
|
tooltip-format = "MPD (connected)";
|
||||||
tooltip-format-disconnected = "MPD (disconnected)";
|
tooltip-format-disconnected = "MPD (disconnected)";
|
||||||
on-scroll-up = "${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 volume -2";
|
on-scroll-down = "${pkgs.mpc_cli}/bin/mpc -q -h ${config.services.mpd.network.listenAddress} volume -2";
|
||||||
consume-icons = {
|
consume-icons = {
|
||||||
on = " ";
|
on = " ";
|
||||||
};
|
};
|
||||||
|
@ -443,7 +467,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
phone = " ";
|
phone = " ";
|
||||||
portable = " ";
|
portable = " ";
|
||||||
};
|
};
|
||||||
on-click-right = "pavucontrol";
|
on-click-right = "${pkgs.pavucontrol}/bin/pavucontrol";
|
||||||
};
|
};
|
||||||
network = {
|
network = {
|
||||||
format-wifi = "{essid} ({signalStrength}%) 直 ";
|
format-wifi = "{essid} ({signalStrength}%) 直 ";
|
||||||
|
@ -452,13 +476,13 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
format-disconnected = "Disconnected ⚠ ";
|
format-disconnected = "Disconnected ⚠ ";
|
||||||
format-alt = "{ifname}: {ipaddr}/{cidr}";
|
format-alt = "{ifname}: {ipaddr}/{cidr}";
|
||||||
tooltip = false;
|
tooltip = false;
|
||||||
on-click-right = "alacritty -e nmtui";
|
on-click-right = "${config.programs.alacritty.package}/bin/alacritty -e ${pkgs.networkmanager}/bin/nmtui";
|
||||||
};
|
};
|
||||||
"custom/vpn" = {
|
"custom/vpn" = {
|
||||||
interval = 10;
|
interval = 10;
|
||||||
exec = pkgs.writeShellScript "vpn-state" ''
|
exec = pkgs.writeShellScript "vpn-state" ''
|
||||||
ip -j link \
|
${pkgs.iproute}/bin/ip -j link \
|
||||||
| jq --unbuffered --compact-output '
|
| ${pkgs.jq}/bin/jq --unbuffered --compact-output '
|
||||||
[[.[].ifname | select(. | startswith("mullvad"))][] | split("-")[1] + " ${thinsp}"] as $conns
|
[[.[].ifname | select(. | startswith("mullvad"))][] | split("-")[1] + " ${thinsp}"] as $conns
|
||||||
| { text: ($conns[0] // ""), class: (if $conns | length > 0 then "connected" else "disconnected" end) }'
|
| { text: ($conns[0] // ""), class: (if $conns | length > 0 then "connected" else "disconnected" end) }'
|
||||||
'';
|
'';
|
||||||
|
@ -550,7 +574,7 @@ lib.mkIf nixosConfig.sbruder.gui.enable {
|
||||||
Service = {
|
Service = {
|
||||||
ExecStartPre = toString (pkgs.writeShellScript "reset-mako-inhibit-state" ''
|
ExecStartPre = toString (pkgs.writeShellScript "reset-mako-inhibit-state" ''
|
||||||
set -e
|
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}
|
echo 0 > ${lib.escapeShellArg makoInhibitStateFile}
|
||||||
'');
|
'');
|
||||||
ExecStart = "${pkgs.mako}/bin/mako";
|
ExecStart = "${pkgs.mako}/bin/mako";
|
||||||
|
|
Loading…
Reference in a new issue