phone: disable swayidle

This commit is contained in:
chayleaf 2023-12-24 21:08:49 +07:00
parent 42f89647cb
commit 7510f37117
Signed by: chayleaf
GPG key ID: 78171AD46227E68E
2 changed files with 21 additions and 21 deletions

View file

@ -5,7 +5,7 @@ rofiSway = config.programs.rofi.finalPackage;
rofiI3 = pkgs.rofi.override { plugins = config.programs.rofi.plugins; }; rofiI3 = pkgs.rofi.override { plugins = config.programs.rofi.plugins; };
audioNext = pkgs.writeShellScript "playerctl-next" '' audioNext = pkgs.writeShellScript "playerctl-next" ''
${pkgs.playerctl}/bin/playerctl next ${pkgs.playerctl}/bin/playerctl next
PLAYER=$(${pkgs.playerctl}/bin/playerctl -l | head -n 1) PLAYER=$(${pkgs.playerctl}/bin/playerctl -l | ${pkgs.coreutils}/bin/head -n 1)
# mpdris2 bug: audio wont play after a seek/skip, you have to pause-unpause # mpdris2 bug: audio wont play after a seek/skip, you have to pause-unpause
if [[ "$PLAYER" == "mpd" ]]; then if [[ "$PLAYER" == "mpd" ]]; then
${pkgs.playerctl}/bin/playerctl pause ${pkgs.playerctl}/bin/playerctl pause
@ -16,7 +16,7 @@ audioNext = pkgs.writeShellScript "playerctl-next" ''
audioPrev = pkgs.writeShellScript "playerctl-prev" '' audioPrev = pkgs.writeShellScript "playerctl-prev" ''
# just seek if over 5 seconds into the track # just seek if over 5 seconds into the track
POS=$(${pkgs.playerctl}/bin/playerctl position) POS=$(${pkgs.playerctl}/bin/playerctl position)
PLAYER=$(${pkgs.playerctl}/bin/playerctl -l | head -n 1) PLAYER=$(${pkgs.playerctl}/bin/playerctl -l | ${pkgs.coreutils}/bin/head -n 1)
if [ -n "$POS" ]; then if [ -n "$POS" ]; then
if (( $(echo "$POS > 5.01" | ${pkgs.bc}/bin/bc -l) )); then if (( $(echo "$POS > 5.01" | ${pkgs.bc}/bin/bc -l) )); then
SEEK=1 SEEK=1
@ -49,6 +49,14 @@ dpms-on = pkgs.writeShellScript "sway-dpms-on" ''
${config.wayland.windowManager.sway.package}/bin/swaymsg output "*" power on ${config.wayland.windowManager.sway.package}/bin/swaymsg output "*" power on
${config.wayland.windowManager.sway.package}/bin/swaymsg input type:touch events enabled ${config.wayland.windowManager.sway.package}/bin/swaymsg input type:touch events enabled
''; '';
lock-script = pkgs.writeShellScript "lock-start" ''
${swaylock-start}
${lib.optionalString config.phone.enable
# suspend if nothing is playing
''
${pkgs.playerctl}/bin/playerctl -a status | ${pkgs.gnugrep}/bin/grep Playing >/dev/null || /run/current-system/sw/bin/systemctl suspend
''}
'';
barConfig = { barConfig = {
mode = "overlay"; mode = "overlay";
hiddenState = "hide"; hiddenState = "hide";
@ -98,10 +106,10 @@ commonConfig = {
${lib.optionalString config.phone.enable '' ${lib.optionalString config.phone.enable ''
${pkgs.squeekboard}/bin/squeekboard& ${pkgs.squeekboard}/bin/squeekboard&
${pkgs.wvkbd}/bin/wvkbd-mobintl --hidden -l full,special,cyrillic,emoji& ${pkgs.wvkbd}/bin/wvkbd-mobintl --hidden -l full,special,cyrillic,emoji&
${pkgs.systemd}/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true /run/current-system/sw/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
''} ''}
${pkgs.home-daemon}/bin/home-daemon system76-scheduler& ${pkgs.home-daemon}/bin/home-daemon system76-scheduler&
${pkgs.gnome.zenity}/bin/zenity --password | tee /dev/stdout | (${pkgs.keepassxc}/bin/keepassxc --pw-stdin ~/Nextcloud/keepass.kdbx ~/var/local.kdbx&) ${pkgs.gnome.zenity}/bin/zenity --password | ${pkgs.coreutils}/bin/tee /dev/stdout | (${pkgs.keepassxc}/bin/keepassxc --pw-stdin ~/Nextcloud/keepass.kdbx ~/var/local.kdbx&)
# nextcloud and nheko need secret service access # nextcloud and nheko need secret service access
${pkgs.nextcloud-client}/bin/nextcloud --background& ${pkgs.nextcloud-client}/bin/nextcloud --background&
${pkgs.nheko}/bin/nheko& ${pkgs.nheko}/bin/nheko&
@ -347,6 +355,7 @@ in
"--locked --inhibited --release XF86PowerOff" = lib.mkIf config.phone.enable "exec ${pkgs.writeShellScript "power-key" '' "--locked --inhibited --release XF86PowerOff" = lib.mkIf config.phone.enable "exec ${pkgs.writeShellScript "power-key" ''
if ${config.wayland.windowManager.sway.package}/bin/swaymsg -rt get_outputs | ${pkgs.jq}/bin/jq ".[].power" | ${pkgs.gnugrep}/bin/grep true; then if ${config.wayland.windowManager.sway.package}/bin/swaymsg -rt get_outputs | ${pkgs.jq}/bin/jq ".[].power" | ${pkgs.gnugrep}/bin/grep true; then
${dpms-off} ${dpms-off}
${lock-script}
else else
${dpms-on} ${dpms-on}
fi fi
@ -395,17 +404,8 @@ in
export XDG_SESSION_DESKTOP=sway export XDG_SESSION_DESKTOP=sway
''; '';
}; };
services.swayidle = let services.swayidle = {
lock = pkgs.writeShellScript "lock-start" '' enable = config.wayland.windowManager.sway.enable && !config.phone.enable;
${swaylock-start}
${lib.optionalString config.phone.enable
# suspend if nothing is playing
''
${pkgs.playerctl}/bin/playerctl -a status | ${pkgs.gnugrep}/bin/grep Playing >/dev/null || /run/current-system/sw/bin/systemctl suspend
''}
'';
in {
enable = config.wayland.windowManager.sway.enable;
events = [ events = [
{ event = "before-sleep"; command = toString swaylock-start; } { event = "before-sleep"; command = toString swaylock-start; }
# after-resume, lock, unlock # after-resume, lock, unlock
@ -415,7 +415,7 @@ in
command = toString dpms-off; command = toString dpms-off;
resumeCommand = toString dpms-on; } resumeCommand = toString dpms-on; }
{ timeout = if config.phone.enable then 60 else 600; { timeout = if config.phone.enable then 60 else 600;
command = toString lock; } command = toString lock-script; }
]; ];
}; };
programs.swaylock.settings = rec { programs.swaylock.settings = rec {

View file

@ -186,7 +186,7 @@
interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true";
format = " 󰌌 "; format = " 󰌌 ";
on-click = pkgs.writeShellScript "toggle-keyboard.sh" '' on-click = pkgs.writeShellScript "toggle-keyboard.sh" ''
pkill -x -SIGRTMIN wvkbd-mobintl ${pkgs.procps}/bin/pkill -SIGRTMIN -x wvkbd-mobintl
''; '';
}; };
"custom/c" = { "custom/c" = {
@ -203,17 +203,17 @@
interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true";
format = " 󰌌 "; format = " 󰌌 ";
on-click = pkgs.writeShellScript "toggle-keyboard.sh" '' on-click = pkgs.writeShellScript "toggle-keyboard.sh" ''
if ${pkgs.systemd}/bin/busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible | ${pkgs.gnugrep}/bin/grep true; then if /run/current-system/sw/bin/busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible | ${pkgs.gnugrep}/bin/grep true; then
${pkgs.systemd}/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false /run/current-system/sw/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false
else else
${pkgs.systemd}/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true /run/current-system/sw/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
fi fi
''; '';
}; };
"custom/f" = { "custom/f" = {
interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true";
format = " X "; format = " X ";
on-click = "${pkgs.sway}/bin/swaymsg kill"; on-click = "${config.wayland.windowManager.sway.package}/bin/swaymsg kill";
}; };
} }
]; ];