Score:0

Problem with running related scripts via systemd

my flag

I tried to run three related script automatically (launcher,set-app,checkapp.py) using systemd timer and systemd service, first script check the python script (gui app) if he already running, after that he restart the python gui app, my problem is when i trying to run systemd service, it close the gui app

this is the first script (launcher):

#!/bin/bash
/usr/share/checkapp/set-app 
exit 0

and this is the second one (set-app):

#!/bin/bash
CHECK_PRO="$(ps -ef | grep '[p]ython3 /usr/share/checkapp/checkapp.py' | awk '{print $2}')"
if [ "${CHECK_PRO}" != "" ]; then
    kill -9 $CHECK_PRO
    python3 /usr/share/checkapp/checkapp.py show &
fi
exit 0

and this is the last one (checkapp.py):

#!/usr/bin/env python3


import os
import signal
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
gi.require_version('Gtk', '3.0')

APPINDICATOR_ID = 'checkapp'
app_ico = '/usr/share/checkapp/logo.svg'

def main():
    indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath(app_ico), appindicator.IndicatorCategory.SYSTEM_SERVICES)
    indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
    indicator.set_menu(build_menu())
    gtk.main()

def build_menu():
    menu = gtk.Menu()
    software_cen = gtk.MenuItem('Software Center')
    software_cen.connect('activate', software_center)
    menu.append(software_cen) 
    menu.show_all()
    return menu

def software_center(source):
    os.system('pkexec /usr/sbin/synaptic')
if __name__ == "__main__":
    signal.signal(signal.SIGINT, signal.SIG_DFL)
main()

and this is the checkapp.service file :

[Unit]
Description=checkapp
[Service]
ExecStart=/usr/share/checkapp/launcher

and this is checkapp.timer file:

[Unit]
Description=Running checkapp every 2 hour
RefuseManualStart=no                       
RefuseManualStop=no                       

[Timer]
OnBootSec=20
OnUnitActiveSec=120min
AccuracySec=1ms
Unit=checkapp.service

[Install]
WantedBy=timers.target
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.