[Unit]
Description=Workaround gamescope not having the correct caps
ConditionFileIsExecutable=/usr/bin/gamescope
After=local-fs.target

[Service]
Type=oneshot
# Copy if it doesn't exist
ExecStartPre=/usr/bin/bash -c "[ -x /usr/local/bin/.gamescope ] || /usr/bin/cp /usr/bin/gamescope /usr/local/bin/.gamescope"
# This is faster than using .mount unit. Also allows for the previous line/cleanup
ExecStartPre=/usr/bin/mount --bind /usr/local/bin/.gamescope /usr/bin/gamescope
# Fix caps
ExecStart=/usr/sbin/setcap 'cap_sys_nice=eip' /usr/bin/gamescope
# Clean-up after ourselves
ExecStop=/usr/bin/umount /usr/bin/gamescope
ExecStop=/usr/bin/rm /usr/local/bin/.gamescope
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
