[Unit]
Description=Workaround KDE System Monitor not having the correct caps
ConditionFileIsExecutable=/usr/libexec/ksysguard/ksgrd_network_helper
After=local-fs.target

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

[Install]
WantedBy=multi-user.target
