wmstartup: Add more services, move service logic out of common.bash
This commit is contained in:
parent
188961da25
commit
c0b14dba2d
@ -8,6 +8,8 @@
|
||||
|
||||
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
|
||||
@ -15,20 +17,27 @@ function svc_log() {
|
||||
}
|
||||
|
||||
function prestart() {
|
||||
if pgrep $service_proccess > /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() {
|
||||
if ! prestart; then
|
||||
svc_log "Failed pre-start checks"
|
||||
return 1
|
||||
fi
|
||||
svc_log "Starting"
|
||||
$service_process > /dev/null 2>&1 &
|
||||
$service_process $service_flags > /dev/null 2>&1 &
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -48,6 +57,11 @@ function stop() {
|
||||
|
||||
function isup() {
|
||||
pgrep "$service_process" > /dev/null 2>&1
|
||||
isup-extra $?
|
||||
return $?
|
||||
}
|
||||
|
||||
function isup-extra() {
|
||||
return $1
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,11 @@ source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Compton"
|
||||
service_process="compton"
|
||||
|
||||
function start() {
|
||||
function prestart-extra() {
|
||||
if [[ "$HOST" == "vm-*" ]]; then
|
||||
svc_log "Will not start: in a VM"
|
||||
return 0
|
||||
else
|
||||
svc_log "Starting"
|
||||
$service_process > /dev/null 2>&1 &
|
||||
return 0
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -11,10 +11,6 @@ service_name="Conky"
|
||||
service_process="conky"
|
||||
|
||||
function start() {
|
||||
if ! prestart; then
|
||||
svc_log "Failed pre-start checks"
|
||||
return 1
|
||||
fi
|
||||
for file in $XDG_CONFIG_HOME/conky/*.conf; do
|
||||
svc_log "Starting with config $file"
|
||||
conky -c $file > /dev/null 2>&1 &
|
||||
|
13
.config/dtfscripts/services/dropbox.dtf
Executable file
13
.config/dtfscripts/services/dropbox.dtf
Executable file
@ -0,0 +1,13 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Simple wmstartup service
|
||||
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Dropbox"
|
||||
service_process="dropbox"
|
||||
service_kill_on_reload="false"
|
||||
|
@ -11,10 +11,6 @@ service_name="Polybar"
|
||||
service_process="polybar"
|
||||
|
||||
function start() {
|
||||
if ! prestart; then
|
||||
svc_log "Failed pre-start checks"
|
||||
return 1
|
||||
fi
|
||||
export PB_MONITOR=$(xrandr -q | awk '/primary/{print $1}')
|
||||
svc_log "Starting primary on monitor $PB_MONITOR"
|
||||
polybar -r primary& > /dev/null 2>&1
|
||||
|
13
.config/dtfscripts/services/redshift.dtf
Executable file
13
.config/dtfscripts/services/redshift.dtf
Executable file
@ -0,0 +1,13 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Simple wmstartup service
|
||||
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Redshift"
|
||||
service_process="redshift"
|
||||
service_kill_on_reload="false"
|
||||
|
@ -10,10 +10,7 @@ source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="sxhkd"
|
||||
service_process="sxhkd"
|
||||
|
||||
function prestart() {
|
||||
if ! which $service_process > /dev/null 2>&1; then
|
||||
svc_log "Could not find process"
|
||||
fi
|
||||
function prestart-extra() {
|
||||
if ! pgrep bspwm > /dev/null 2>&1; then
|
||||
svc_log "Not under bspwm"
|
||||
return 1
|
||||
|
14
.config/dtfscripts/services/syncthing.dtf
Executable file
14
.config/dtfscripts/services/syncthing.dtf
Executable file
@ -0,0 +1,14 @@
|
||||
#! /usr/bin/env bash
|
||||
#
|
||||
# Simple wmstartup service
|
||||
# Copyright (C) 2018 salt <salt@lap-th-e560-0>
|
||||
#
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
source $DTF_SERVICES_DIR/common.bash
|
||||
service_name="Syncthing"
|
||||
service_process="syncthing"
|
||||
service_kill_on_reload="false"
|
||||
service_flags="--no-browser"
|
||||
|
@ -72,10 +72,14 @@ fi
|
||||
for service in $DTF_SERVICES_DIR/*.dtf; do
|
||||
(
|
||||
source $service
|
||||
if isup; then
|
||||
stop
|
||||
if ! prestart; then
|
||||
svc_log "Failed pre-start checks"
|
||||
else
|
||||
if isup && [[ "$service_kill_on_reload" == "true" ]] ; then
|
||||
stop
|
||||
fi
|
||||
start
|
||||
fi
|
||||
start
|
||||
)
|
||||
done
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user