{"id":24221615,"url":"https://github.com/michdo93/openhab-application-checker","last_synced_at":"2026-03-10T14:05:41.372Z","repository":{"id":58166302,"uuid":"529970752","full_name":"Michdo93/openHAB-Application-Checker","owner":"Michdo93","description":"Use openHAB and the Exec Action for checking if an application is running or not. If it is running an Switch item will have the state ON. If not the state will be OFF.","archived":false,"fork":false,"pushed_at":"2022-09-06T10:39:31.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T00:45:37.205Z","etag":null,"topics":["openhab","openhab-binding","openhab-configs","openhab-configuration","openhab-items","openhab-rules","openhab2","openhab3"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Michdo93.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-28T20:21:53.000Z","updated_at":"2022-09-23T13:05:28.000Z","dependencies_parsed_at":"2023-01-17T21:11:04.487Z","dependency_job_id":null,"html_url":"https://github.com/Michdo93/openHAB-Application-Checker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Michdo93/openHAB-Application-Checker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FopenHAB-Application-Checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FopenHAB-Application-Checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FopenHAB-Application-Checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FopenHAB-Application-Checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Michdo93","download_url":"https://codeload.github.com/Michdo93/openHAB-Application-Checker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Michdo93%2FopenHAB-Application-Checker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30336122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T12:41:07.687Z","status":"ssl_error","status_checked_at":"2026-03-10T12:41:06.728Z","response_time":106,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["openhab","openhab-binding","openhab-configs","openhab-configuration","openhab-items","openhab-rules","openhab2","openhab3"],"created_at":"2025-01-14T06:19:53.880Z","updated_at":"2026-03-10T14:05:41.351Z","avatar_url":"https://github.com/Michdo93.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# openHAB-Application-Checker\nUse openHAB and the [Exec Action](https://www.openhab.org/docs/configuration/actions.html#exec-actions) for checking if an application is running or not. If it is running an Switch item will have the state ON. If not the state will be OFF.\n\n## Items\n\nYou can use as example following items:\n\n```\nSwitch Firefox \"Firefox\"\nSwitch VirtualBox \"VirtualBox\"\nSwitch Kodi \"Kodi\"\nSwitch VLC \"VLC\"\n```\n\n## Sitemaps\n\nYou can add your items as example to your sitemap like shown in the following:\n\n```\nSwitch item=Firefox label=\"Firefox\"\nSwitch item=VirtualBox label=\"VirtualBox\"\nSwitch item=Kodi label=\"Kodi\"\nSwitch item=VLC label=\"VLC\"\n```\n\n## Rules\n\nAt first you have to add following to your `/etc/openhab/misc/exec.whitelist` file:\n\n```\n/bin/ps aux | /bin/grep [f]irefox | /usr/bin/wc -l\n/bin/ps aux | /bin/grep [V]irtualBox | /usr/bin/wc -l\n/bin/ps aux | /bin/grep [k]odi | /usr/bin/wc -l\n/bin/ps aux | /bin/grep [v]lc | /usr/bin/wc -l\n```\n\nOff course you can run this over `SSH` and check if an application is running on a remote computer. Then as example `/bin/ps aux | /bin/grep [v]lc | /usr/bin/wc -l` will change to `/usr/bin/sshpass -p \u003cpassword\u003e /usr/bin/ssh -tt -o StrictHostKeyChecking=no \u003cuser\u003e@\u003cip\u003e \"/bin/ps aux | /bin/grep [v]lc | /usr/bin/wc -l\" 2\u003e /dev/null`. Then you have to replace `\u003cuser\u003e` and `\u003cpassword\u003e` with the username and password of your remote computer. Also you have to replace `\u003cip\u003e` with the ip address of your remote computer.\n\n```\n/usr/bin/sshpass -p \u003cpassword\u003e /usr/bin/ssh -tt -o StrictHostKeyChecking=no \u003cuser\u003e@\u003cip\u003e \"/bin/ps aux | /bin/grep [f]irefox | /usr/bin/wc -l\" 2\u003e /dev/null\n/usr/bin/sshpass -p \u003cpassword\u003e /usr/bin/ssh -tt -o StrictHostKeyChecking=no \u003cuser\u003e@\u003cip\u003e \"/bin/ps aux | /bin/grep [V]irtualBox | /usr/bin/wc -l\" 2\u003e /dev/null\n/usr/bin/sshpass -p \u003cpassword\u003e /usr/bin/ssh -tt -o StrictHostKeyChecking=no \u003cuser\u003e@\u003cip\u003e \"/bin/ps aux | /bin/grep [k]odi | /usr/bin/wc -l\" 2\u003e /dev/null\n/usr/bin/sshpass -p \u003cpassword\u003e /usr/bin/ssh -tt -o StrictHostKeyChecking=no \u003cuser\u003e@\u003cip\u003e \"/bin/ps aux | /bin/grep [v]lc | /usr/bin/wc -l\" 2\u003e /dev/null\n```\n\nWith `ps aux` you can check which processes are running on a (remote) computer. With `grep` you can filter for a process. A better usage it to filter by using the application name like `vlc`. The problem is that using `grep` would also create a process. So if your application is not running there would be one process because you are using `grep` to look if there is a process or not. To fix it you can `grep` as example `[v]lc` instead of `vlc`. This means if `vlc` is not running there would be no response. If `vlc` is running there would be minimum one process because `vlc` can be running more than once at one time. At least we use `wc` for counting each line. Each process would have one line. So if `vlc` is not running with `wc` your result is `0`. If `vlc` is running with `wc` the result is the number of times `vlc` is running.\n\nTo check if an application is running or not, you either have to trigger it manually, which means you would need another `Switch` item. When its `state` changes to `ON`, a `Rule` is executed that checks if the application is running or not as just described. A better approach is to simply check periodically whether an application is running or not. This is a [time-based trigger](https://www.openhab.org/docs/configuration/rules-dsl.html#time-based-triggers). A `time-based trigger` can use `cron expression`. So we need a `cron expression` as trigger for our rule.\n\n**However, this leads to a major problem. How often or at what periodic time interval should one check whether an application is running or not? Every second? Every minute? Every hour?**\n\nChecking too often puts a lot of load on the computer. Checking too infrequently, on the other hand, leads to an inaccurate result. Possibly then to an erroneous one, because it was still assumed that an application is running and in the meantime it has already been terminated. Or just the other way around: The application is running in the meantime, but it is assumed that it is not running.\n\nSo the following rule is just an example of how this concept might work:\n\n```\nrule \"Application checker\"\nwhen\n    Time cron \"0/1 * * ? * * *\"\nthen\n    var firefox = executeCommandLine(\"/bin/ps\", \"aux\", \"|\", \"/bin/grep\", \"[f]irefox\", \"|\", \"/usr/bin/wc\", \"-l\")\n    firefox = Integer.parseInt(firefox)\n    logInfo(\"application check firefox\", \"the value is {}\", firefox)\n    if (firefox \u003e 0) {\n        Firefox.postUpdate(ON)\n    } else {\n        Firefox.postUpdate(OFF)\n    }\n    \n    var virtualbox = executeCommandLine(\"/bin/ps\", \"aux\", \"|\", \"/bin/grep\", \"[V]irtualBox\", \"|\", \"/usr/bin/wc\", \"-l\")\n    virtualbox = Integer.parseInt(virtualbox)\n    logInfo(\"application check virtualbox\", \"the value is {}\", virtualbox)\n    if (virtualbox \u003e 0) {\n        VirtualBox.postUpdate(ON)\n    } else {\n        VirtualBox.postUpdate(OFF)\n    }\n    \n    var kodi = executeCommandLine(\"/bin/ps\",\"aux\",\"|\",\"/bin/grep\",\"[k]odi\",\"|\",\"/usr/bin/wc\",\"-l\")\n    kodi = Integer.parseInt(kodi)\n    logInfo(\"application check kodi\", \"the value is {}\", kodi)\n    if (kodi \u003e 0) {\n        Kodi.postUpdate(ON)\n    } else {\n        Kodi.postUpdate(OFF)\n    }\n    \n    var vlc = executeCommandLine(\"/bin/ps\",\"aux\",\"|\",\"/bin/grep\",\"[v]lc\",\"|\",\"/usr/bin/wc\",\"-l\")\n    vlc = Integer.parseInt(vlc)\n    logInfo(\"application check vlc\", \"the value is {}\", vlc)\n    if (vlc \u003e 0) {\n        VLC.postUpdate(ON)\n    } else {\n        VLC.postUpdate(OFF)\n    }\nend\n```\n\nIf you want to use it over `ssh` it looks like following:\n\n```\nrule \"Application checker\"\nwhen\n    Time cron \"0/1 * * ? * * *\"\nthen\n    var firefox = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"|\",\"/bin/grep\",\"[f]irefox\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    firefox = firefox.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    firefox = firefox.replace(\"\\r\\n\", \"\")\n    firefox = Integer.parseInt(firefox)\n    logInfo(\"application check firefox\", \"the value is {}\", firefox)\n    if (firefox \u003e 0) {\n        Firefox.postUpdate(ON)\n    } else {\n        Firefox.postUpdate(OFF)\n    }\n\n    var virtualbox = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"|\",\"/bin/grep\",\"[V]irtualBox\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    virtualbox = virtualbox.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    virtualbox = virtualbox.replace(\"\\r\\n\", \"\")\n    virtualbox = Integer.parseInt(virtualbox)\n    logInfo(\"application check virtualbox\", \"the value is {}\", virtualbox)\n    if (virtualbox \u003e 0) {\n        VirtualBox.postUpdate(ON)\n    } else {\n        VirtualBox.postUpdate(OFF)\n    }\n    \n    var kodi = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"|\",\"/bin/grep\",\"[k]odi\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    kodi = kodi.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    kodi = kodi.replace(\"\\r\\n\", \"\")\n    kodi = Integer.parseInt(kodi)\n    logInfo(\"application check kodi\", \"the value is {}\", kodi)\n    if (kodi \u003e 0) {\n        kodi.postUpdate(ON)\n    } else {\n        kodi.postUpdate(OFF)\n    }\n\n    var vlc = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"|\",\"/bin/grep\",\"[v]lc\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    vlc = vlc.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    vlc = vlc.replace(\"\\r\\n\", \"\")\n    vlc = Integer.parseInt(vlc)\n    logInfo(\"application check vlc\", \"the value is {}\", vlc)\n    if (vlc \u003e 0) {\n        VLC.postUpdate(ON)\n    } else {\n        VLC.postUpdate(OFF)\n    }\nend\n```\n\nIf you are using `Windows`, I suggest you install [PsTools](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) and [Git Bash](https://git-scm.com/downloads). Both should be added to the `PATH` variable, then you can use the following rule:\n\n```\nrule \"Application checker\"\nwhen\n    Time cron \"0/1 * * ? * * *\"\nthen\n    var firefox = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"-W\",\"|\",\"/bin/grep\",\"firefox\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    firefox = firefox.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    firefox = firefox.replace(\"\\r\\n\", \"\")\n    firefox = Integer.parseInt(firefox)\n    logInfo(\"application check firefox\", \"the value is {}\", firefox)\n    if (firefox \u003e 0) {\n        Firefox.postUpdate(ON)\n    } else {\n        Firefox.postUpdate(OFF)\n    }\n\n    var virtualbox = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"-W\",\"|\",\"/bin/grep\",\"VirtualBox\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    virtualbox = virtualbox.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    virtualbox = virtualbox.replace(\"\\r\\n\", \"\")\n    virtualbox = Integer.parseInt(virtualbox)\n    logInfo(\"application check virtualbox\", \"the value is {}\", virtualbox)\n    if (virtualbox \u003e 0) {\n        VirtualBox.postUpdate(ON)\n    } else {\n        VirtualBox.postUpdate(OFF)\n    }\n    \n    var kodi = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"-W\",\"|\",\"/bin/grep\",\"kodi\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    kodi = kodi.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    kodi = kodi.replace(\"\\r\\n\", \"\")\n    kodi = Integer.parseInt(kodi)\n    logInfo(\"application check kodi\", \"the value is {}\", kodi)\n    if (kodi \u003e 0) {\n        kodi.postUpdate(ON)\n    } else {\n        kodi.postUpdate(OFF)\n    }\n\n    var vlc = executeCommandLine(Duration.ofSeconds(1), \"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-tt\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"ps\",\"aux\",\"-W\",\"|\",\"/bin/grep\",\"vlc\",\"|\",\"/usr/bin/wc\",\"-l\",\"2\u003e\",\"/dev/null\")\n    vlc = vlc.replace(\"Connection to \u003cip\u003e closed.\", \"\")\n    vlc = vlc.replace(\"\\r\\n\", \"\")\n    vlc = Integer.parseInt(vlc)\n    logInfo(\"application check vlc\", \"the value is {}\", vlc)\n    if (vlc \u003e 0) {\n        VLC.postUpdate(ON)\n    } else {\n        VLC.postUpdate(OFF)\n    }\nend\n```\n\nAnd of course you can add other rules for running or stopping an application like following:\n\n```\nrule \"Run VLC\"\nwhen\n    Item VLC received command ON\nthen\n    executeCommandLine(\"DISPLAY=:0\",\"/usr/bin/vlc\",\"--fullscreen\")\nend\n\nrule \"Quit VLC\"\nwhen\n    Item VLC received command OFF\nthen\n    executeCommandLine(\"/usr/bin/sudo\",\"killall\",\"/usr/bin/vlc\")\nend\n```\n\n\nOr if you want to do it over `ssh` it looks as example like following:\n\n```\nrule \"Run VLC\"\nwhen\n    Item VLC received command ON\nthen\n    executeCommandLine(\"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-t\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"DISPLAY=:0\",\"/usr/bin/vlc\",\"--fullscreen\")\nend\n\nrule \"Quit VLC\"\nwhen\n    Item VLC received command OFF\nthen\n    executeCommandLine(\"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-t\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"/usr/bin/sudo\",\"killall\",\"/usr/bin/vlc\")\nend\n```\n\nIf you will run it on `Windows` you need [PsExec](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) and [PsKill](https://docs.microsoft.com/en-us/sysinternals/downloads/pskill) from the `PsTools`:\n\n```\nrule \"Run VLC\"\nwhen\n    Item VLC received command ON\nthen\n    executeCommandLine(\"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-t\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"PsExec\",\"-i\",\"1\",\"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe\",\"--fullscreen\")\nend\n\nrule \"Quit VLC\"\nwhen\n    Item VLC received command OFF\nthen\n    executeCommandLine(\"/usr/bin/sshpass\",\"-p\",\"\u003cpassword\u003e\",\"/usr/bin/ssh\",\"-t\",\"-o\",\"StrictHostKeyChecking=no\",\"\u003cuser\u003e@\u003cip\u003e\",\"PsKill\",\"-t\",\"vlc.exe\")\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichdo93%2Fopenhab-application-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichdo93%2Fopenhab-application-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichdo93%2Fopenhab-application-checker/lists"}