#!/sbin/openrc-run # Copyright 2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 name=${RC_SVCNAME} description="kill todesk-hold when todesk desktop running" supervisor="supervise-daemon" healthcheck_delay=5 healthcheck_timer=1 respawn_max=0 command="/usr/bin/sleep" command_args="infinity" depend() { after display-manager } healthcheck() { psidt=$(ps -ef | tr -s " " | cut -d " " -f 2,8 | grep '/opt.*bin/todesk' | grep -v todeskd | grep -v $0 | awk '{print $1}') psidr=$(ps -ef | tr -s " " | cut -d " " -f 2,8,9 | grep 'sh /opt/todesk/bin/todesk-hold' | grep -v grep | grep -v $0 | awk '{print $1}') [[ ! -n $psidt ]] || [[ ! -n $psidr ]] || return 1 } stop_hold() { psidr=$(ps -ef | tr -s " " | cut -d " " -f 2,8,9 | grep 'sh /opt/todesk/bin/todesk-hold' | grep -v grep | grep -v $0 | awk '{print $1}') psids=`pstree -p ${psidr} | cut -d '(' -f 3` [[ ! -n $psidr ]] || /bin/kill $psidr & [[ ! -n $psids ]] || /bin/kill ${psids%%*)} & return 0 } unhealthy() { stop_hold }