Skip to content

Commit

Permalink
feat(picom): added guard to disable picom during gaming
Browse files Browse the repository at this point in the history
Picom has graphic bugs which I can't fix it. I created service that
stops picom after launch steam
  • Loading branch information
Wittano committed Jul 20, 2024
1 parent 87aced9 commit d93ce60
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions modules/desktop/submodules/picom.nix
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
{ pkgs, lib, ... }:
let guardName = "gaming-picom-guard"; in
with lib;
let
restartPicomScript = pkgs.wrietShellApplication {
name = "restart-picom";
runtimeInputs = with pkgs; [ toybox systemd ];
text = ''
if [ systemctl --user is-active picom.service ]; then
exit 0
fi
while true; do
if [ -z "$(pgrep--ignore-case steam)" ]; then
systemd --user start picom.service
fi
sleep 1
done
'';
};
in
{
config = {
systemd.user.services."steam-picom-guard" = {
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
after = [ "picom.service" ];
systemd.user = {
services.${guardName} = {
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
after = [ "picom.service" ];
path = with pkgs; [ systemd toybox ];
script = ''
while true; do
if ! pgrep --ignore-case steam > /dev/null; then
systemctl --user start picom.service
break
fi
sleep 1
serviceConfig = {
ExecCondition = "${pkgs.toybox}/bin/pgrep --ignore-case steam";
ExecStart = meta.getExe restartPicomScript;
RestartSec = 30;
Restart = "always";
if systemctl --user is-active picom.service > /dev/null; then
systemctl --user stop picom.service
fi
done
'';
postStop = "systemctl --user start picom.service";

serviceConfig.ExecCondition = "${pkgs.toybox}/bin/pgrep --ignore-case steam";
};
timers.${guardName} = {
wantedBy = [ "${guardName}.service" ];
timerConfig.OnActiveSec = "1m";
};
};

Expand Down

0 comments on commit d93ce60

Please sign in to comment.