wmstartup: Move common service functions out of individual services
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# wmstartup service common functions
|
||||
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
service_name="unnamed_service"
|
||||
service_process="true"
|
||||
service_kill_on_reload="true"
|
||||
service_flags=""
|
||||
|
||||
function svc_log() {
|
||||
if [ -z ${1+x} ]; then return 1; fi
|
||||
dtf_log "$service_name: $1"
|
||||
}
|
||||
|
||||
function prestart() {
|
||||
if pgrep $service_process > /dev/null 2>&1; then
|
||||
svc_log "Already running"
|
||||
return 1
|
||||
fi
|
||||
if ! which $service_process > /dev/null 2>&1; then
|
||||
svc_log "Could not find process"
|
||||
return 1
|
||||
fi
|
||||
if ! prestart-extra; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function prestart-extra() {
|
||||
return 0
|
||||
}
|
||||
|
||||
function start() {
|
||||
svc_log "Starting"
|
||||
$service_process $service_flags > /dev/null 2>&1 &
|
||||
return 0
|
||||
}
|
||||
|
||||
function stop() {
|
||||
svc_log "Stopping"
|
||||
killall $service_process &
|
||||
for i in {1..100}; do
|
||||
if ! isup; then break; fi
|
||||
sleep 0.01
|
||||
if (( $i > 99 )); then
|
||||
svc_log "Stopping with prejudice"
|
||||
killall -9 $service_process
|
||||
fi
|
||||
done
|
||||
return $?
|
||||
}
|
||||
|
||||
function isup() {
|
||||
pgrep "$service_process" > /dev/null 2>&1
|
||||
isup-extra $?
|
||||
return $?
|
||||
}
|
||||
|
||||
function isup-extra() {
|
||||
return $1
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Compton"
|
||||
service_process="compton"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Conky"
|
||||
service_process="conky"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Dropbox"
|
||||
service_process="dropbox"
|
||||
service_kill_on_reload="false"
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Dunst"
|
||||
service_process="dunst"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Krunner"
|
||||
service_process="krunner"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Plasma"
|
||||
service_process="plasmashell"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Polybar"
|
||||
service_process="polybar"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Redshift"
|
||||
service_process="redshift"
|
||||
service_kill_on_reload="false"
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="sxhkd"
|
||||
service_process="sxhkd"
|
||||
|
||||
|
@@ -6,7 +6,6 @@
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Syncthing"
|
||||
service_process="syncthing"
|
||||
service_kill_on_reload="false"
|
||||
|
Reference in New Issue
Block a user