diff --git a/package/draft/launcherctl-draft b/package/draft/launcherctl-draft new file mode 100644 index 000000000..a3c0b9db2 --- /dev/null +++ b/package/draft/launcherctl-draft @@ -0,0 +1,93 @@ +#!/bin/bash +set -e +draft_pid() { + systemctl show --no-pager --property MainPID draft.service | sed 's|MainPID=||' +} +kill_pid() { + pid="$1" + if [[ "$(awk '{print $3}' "/proc/${pid}/stat")" == "T" ]]; then + kill -CONT "$pid" + fi + kill -TERM "$pid" + # Wait 5s for process to exit + start="$(date +'%s')" + while kill -0 "$pid" 2> /dev/null; do + sleep 0.5 + if [ "$(date +'%s')" -gt $((start + 5)) ]; then + break + fi + done + if kill -0 "$pid" 2> /dev/null; then + # If process is still running, force kill it + kill -KILL "$pid" + fi +} +case "$1" in + is-active) + systemctl is-active --quiet draft.service + ;; + is-enabled) + systemctl is-enabled --quiet draft.service + ;; + logs) + if [ $# -eq 2 ] && [[ "$2" == "-f" ]] || [[ "$2" == "--follow" ]]; then + journalctl --follow --all --unit draft.service + else + journalctl --no-pager --all --unit draft.service + fi + ;; + start) + systemctl start draft.service + ;; + stop) + systemctl stop draft.service + ;; + enable) + systemctl enable draft.service + ;; + disable) + systemctl disable draft.service + ;; + apps) + find {/opt,}/etc/draft -maxdepth 1 -type f | while read -r file; do + grep 'name=' "$file" | sed 's|^name=||' + done + ;; + close) + find {/opt,}/etc/draft -maxdepth 1 -type f | while read -r file; do + if [[ "$(grep 'name=' "$file" | sed 's|^name=||')" == "$2" ]]; then + term="$(grep 'term=' "$file" | sed 's|^term=||')" + if [ -z "$term" ]; then + echo "No term= configuration specified for ${2}" + exit 1 + fi + $term + call="$(grep 'call=' "$file" | sed 's|^call=||')" + name="$(grep 'name=' "$file" | sed 's|^name=||')" + /opt/libexec/ps-procps-ng --ppid "$(draft_pid)" -o pid | tail -n +2 | while read -r pid; do + if [[ "$(tr -d '\0' < "/proc/${pid}/cmdline")" == "$call" ]]; then + kill_pid "$pid" + break + fi + done + fi + done + ;; + running) + pid=$(draft_pid) + find {/opt,}/etc/draft -maxdepth 1 -type f | while read -r file; do + call="$(grep 'call=' "$file" | sed 's|^call=||')" + name="$(grep 'name=' "$file" | sed 's|^name=||')" + /opt/libexec/ps-procps-ng --ppid "$(draft_pid)" -o pid | tail -n +2 | while read -r pid; do + if [[ "$(tr -d '\0' < "/proc/${pid}/cmdline")" == "$call" ]]; then + echo "$name" + break + fi + done + done + ;; + *) + echo "Draft does not support this method" + exit 1 + ;; +esac diff --git a/package/draft/package b/package/draft/package index aac94f8e6..b0134f6e5 100644 --- a/package/draft/package +++ b/package/draft/package @@ -5,22 +5,24 @@ pkgnames=(draft) pkgdesc="Launcher which wraps around the standard interface" url=https://github.com/dixonary/draft-reMarkable -pkgver=0.2.0-22 +pkgver=0.2.0-23 timestamp=2020-07-20T10:23Z section="launchers" maintainer="Mattéo Delabre " license=Apache-2.0 -installdepends=(xochitl display) +installdepends=(xochitl display procps-ng-ps) flags=(patch_rm2fb) image=qt:v2.1 source=( https://github.com/dixonary/draft-reMarkable/archive/5bd660a2fd07eba166c6110d2b48cfc58ee67e58.zip draft.service + launcherctl-draft ) sha256sums=( c41d7a4fd537c54d787018fd764421dbf7dd64306ca800875283e05eef99173e SKIP + SKIP ) build() { @@ -46,21 +48,25 @@ package() { mv "$pkgdir"/opt/etc/draft/{99-,}shutdown install -D -m 644 -t "$pkgdir"/lib/systemd/system "$srcdir"/draft.service + install -D -m 755 -t "$pkgdir"/opt/share/launcherctl/"$pkgname" "$srcdir"/launcherctl-draft } configure() { systemctl daemon-reload - if ! is-enabled "$pkgname.service"; then + if ! launcherctl is-current-launcher "$pkgname"; then echo "" echo "Run the following command(s) to use $pkgname as your launcher" - how-to-enable "$pkgname.service" + echo "launcherctl switch-launcher --start $pkgname" echo "" fi } preremove() { - disable-unit "$pkgname.service" + # Just in case more than one launcher is active, do individual checks + if launcherctl is-active-launcher "$pkgname" || launcherctl is-enabled-launcher "$pkgname"; then + launcherctl switch-launcher --start xochitl + fi } postremove() { diff --git a/package/koreader/launcherctl-koreader b/package/koreader/launcherctl-koreader new file mode 100755 index 000000000..6e605d286 --- /dev/null +++ b/package/koreader/launcherctl-koreader @@ -0,0 +1,41 @@ +#!/bin/bash +set -e +case "$1" in + is-active) + systemctl is-active --quiet koreader.service + ;; + is-enabled) + systemctl is-enabled --quiet koreader.service + ;; + logs) + if [ $# -eq 2 ] && [[ "$2" == "-f" ]] || [[ "$2" == "--follow" ]]; then + journalctl --follow --all --unit koreader.service + else + journalctl --no-pager --all --unit koreader.service + fi + ;; + start | launch) + systemctl start koreader.service + ;; + stop | close) + systemctl stop koreader.service + ;; + enable) + systemctl enable koreader.service + ;; + disable) + systemctl disable koreader.service + ;; + apps) + echo "koreader" + ;; + running) + if "$0" is-active; then + echo "koreader" + fi + ;; + *) + echo "KOReader does not support this method" + exit 1 + ;; +esac diff --git a/package/koreader/package b/package/koreader/package index 3d6126a71..8f909dd25 100644 --- a/package/koreader/package +++ b/package/koreader/package @@ -5,7 +5,7 @@ pkgnames=(koreader) pkgdesc="Ebook reader supporting PDF, DjVu, EPUB, FB2 and many more formats" url=https://github.com/koreader/koreader -pkgver=2024.04-1 +pkgver=2024.04-2 timestamp=2024-04-29T19:56:05Z section="readers" maintainer="raisjn " @@ -19,6 +19,7 @@ source=( KOReader.oxide koreader-toltec.service koreader + launcherctl-koreader ) sha256sums=( e6b3a5a2c8cde8ca0c469fe542d6e170502fcf39b9a55e4447a7acd02b4a12c0 @@ -26,6 +27,7 @@ sha256sums=( SKIP SKIP SKIP + SKIP ) package() { @@ -41,6 +43,7 @@ package() { install -D -m 644 "$srcdir"/koreader-toltec.service "$pkgdir"/lib/systemd/system/koreader.service install -D -m 644 -t "$pkgdir"/opt/etc/draft/icons/ "$srcdir"/resources/koreader.png install -D -m 755 -t "$pkgdir"/opt/bin/ "$srcdir"/koreader + install -D -m 755 -t "$pkgdir"/opt/share/launcherctl/"$pkgname" "$srcdir"/launcherctl-koreader } configure() { @@ -51,18 +54,19 @@ configure() { systemctl daemon-reload - if ! is-enabled "$pkgname.service"; then - cat << MSG - -Run the following command(s) to use $pkgname as your launcher -$(how-to-enable "$pkgname.service") - -MSG + if ! launcherctl is-current-launcher "$pkgname"; then + echo "" + echo "Run the following command(s) to use $pkgname as your launcher" + echo "launcherctl switch-launcher --start $pkgname" + echo "" fi } preremove() { - disable-unit "$pkgname.service" + # Just in case more than one launcher is active, do individual checks + if launcherctl is-active-launcher "$pkgname" || launcherctl is-enabled-launcher "$pkgname"; then + launcherctl switch-launcher --start xochitl + fi } postremove() { diff --git a/package/launcherctl/launcherctl b/package/launcherctl/launcherctl new file mode 100755 index 000000000..ff87e6a0f --- /dev/null +++ b/package/launcherctl/launcherctl @@ -0,0 +1,199 @@ +#!/bin/bash +set -e +help() { + echo "Usage: launcherctl " + echo " commands:" + echo " help: Display this message and exit" + echo " status: Current launcher status" + echo " logs [-f|--follow]: View current launcher logs" + echo " list-launchers: List installed launchers" + echo " switch-launcher [--start] : Switch which launcher is active" + echo " start-launcher: Start the current launcher" + echo " stop-launcher: Stop the current launcher" + echo " list-apps: List all application for current launcher" + echo " list-running-apps: List all application for current launcher" + echo " start-app : Start an application with the current launcher" + echo " stop-app : Stop an application with the current launcher" + echo " pause-app : Pause an application with the current launcher" + echo " resume-app : Resume an application with the current launcher" + echo " is-current-launcher : Check if the launcher is the current launcher" + echo " is-enabled-launcher : Check if the launcher is enabled" + echo " is-active-launcher : Check if the launcher is active" +} +data_dir="/opt/share/launcherctl" +launchers() { + /opt/bin/find "$data_dir" -type f -perm '-u+x' | xargs -rn1 basename +} +active_launchers() { + launchers | while read -r launcher; do + if query "$launcher" is-active; then + echo "$launcher" + fi + done +} +enabled_launchers() { + launchers | while read -r launcher; do + if query "$launcher" is-enabled; then + echo "$launcher" + fi + done +} +query() { + launcher="$1" + shift + "${data_dir}/${launcher}" "$@" +} +check_enabled_launchers() { + if [ "$(enabled_launchers | wc -l)" -lt 1 ]; then + echo "More than one launcher is currently enabled!" + echo "Enabled launchers: ${current_launcher}" + exit 1 + fi +} +check_launcher_has_app() { + if ! query "$1" apps | grep -q "$2"; then + echo "Unknown application: ${2}" + exit 1 + fi +} +case "$1" in + help | --help) + help + ;; + logs) + if [ $# -gt 2 ]; then + echo "Too many arguments" + exit 1 + elif [ $# -eq 2 ] && [[ "$2" != "-f" ]] && [[ "$2" != "--follow" ]]; then + echo "Invalid arguments" + exit 1 + fi + check_enabled_launchers + query "$(enabled_launchers)" "$@" + ;; + status) + if [ $# -gt 1 ]; then + echo "Too many arguments" + exit 1 + fi + check_enabled_launchers + current_launcher="$(enabled_launchers)" + echo -e "Launcher: \033[1m${current_launcher}\e[0m" + echo -ne "Status: \033[1m" + if query "$current_launcher" is-active; then + echo -ne "\e[32mrunning" + else + echo -ne "\e[31minactive" + fi + echo -e "\e[0m" + echo -n "Apps: $(query "$current_launcher" running | wc -l) running " + echo "$(query "$current_launcher" apps | wc -l) installed" + ;; + list-launchers) + launchers + ;; + switch-launcher) + if [ $# -lt 2 ]; then + echo "Too few arguments" + exit 1 + elif [ $# -gt 3 ]; then + echo "Too many arguments" + exit 1 + elif [ $# -eq 3 ] && [[ "$2" != "--start" ]]; then + echo "Invalid arguments" + exit 1 + fi + if [ $# -eq 3 ]; then + start=true + shift + else + start=false + fi + if ! [ -f "${data_dir}/${2}" ]; then + echo "${2} is not installed" + exit 1 + fi + enabled_launchers | while read -r launcher; do + if [[ "$launcher" != "$2" ]]; then + query "$launcher" disable + fi + done + if ! query "$2" is-enabled; then + query "$2" enable + fi + if $start; then + "$0" start-launcher + fi + ;; + start-launcher) + check_enabled_launchers + current_launcher="$(enabled_launchers)" + active_launchers | while read -r launcher; do + if [[ "$launcher" != "$current_launcher" ]]; then + query "$launcher" stop + fi + done + if query "$current_launcher" is-active; then + echo "Already started!" + exit + fi + query "$current_launcher" start + ;; + stop-launcher) + active_launchers | while read -r launcher; do + query "$launcher" stop + done + ;; + list-apps) + check_enabled_launchers + query "$(enabled_launchers)" apps + ;; + list-running-apps) + check_enabled_launchers + query "$(enabled_launchers)" running + ;; + list-paused-apps) + check_enabled_launchers + query "$(enabled_launchers)" paused + ;; + start-app) + check_enabled_launchers + launcher="$(enabled_launchers)" + check_launcher_has_app "$launcher" "$2" + query "$launcher" launch "$2" + ;; + stop-app) + check_enabled_launchers + launcher="$(enabled_launchers)" + check_launcher_has_app "$launcher" "$2" + query "$launcher" close "$2" + ;; + pause-app) + check_enabled_launchers + launcher="$(enabled_launchers)" + check_launcher_has_app "$launcher" "$2" + query "$launcher" pause "$2" + ;; + resume-app) + check_enabled_launchers + launcher="$(enabled_launchers)" + check_launcher_has_app "$launcher" "$2" + query "$launcher" resume "$2" + ;; + is-current-launcher) + check_enabled_launchers + if [[ "$(enabled_launchers)" != "$2" ]]; then + exit 1 + fi + ;; + is-enabled-launcher) + query "$2" is-enabled + ;; + is-active-launcher) + query "$2" is-active + ;; + *) + help + exit 1 + ;; +esac diff --git a/package/launcherctl/package b/package/launcherctl/package new file mode 100644 index 000000000..5782c3082 --- /dev/null +++ b/package/launcherctl/package @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Copyright (c) 2023 The Toltec Contributors +# SPDX-License-Identifier: MIT + +pkgnames=(launcherctl) +pkgdesc="Manage your installed launcher" +url=https://toltec-dev.org/ +pkgver=0.0.1-1 +timestamp=2023-12-18T03:32Z +section="launcher" +maintainer="Eeems " +license=MIT + +source=( + launcherctl +) +sha256sums=( + SKIP +) + +package() { + install -D -m 744 -t "$pkgdir"/opt/bin "$srcdir"/launcherctl +} + +configure() { + echo "" + echo "You can use launcherctl to manage your active launcher" + echo "" +} + +preremove() { + launcherctl switch-launcher --start xochitl +} diff --git a/package/oxide/launcherctl-oxide b/package/oxide/launcherctl-oxide new file mode 100755 index 000000000..97ff4a73e --- /dev/null +++ b/package/oxide/launcherctl-oxide @@ -0,0 +1,57 @@ +#!/bin/bash +set -e +case "$1" in + is-active) + systemctl is-active --quiet tarnish.service + ;; + is-enabled) + systemctl is-enabled --quiet tarnish.service + ;; + logs) + if [ $# -eq 2 ] && [[ "$2" == "-f" ]] || [[ "$2" == "--follow" ]]; then + journalctl --follow --all --unit tarnish.service + else + journalctl --no-pager --all --unit tarnish.service + fi + ;; + start) + systemctl start tarnish.service + ;; + stop) + systemctl stop tarnish.service + ;; + enable) + systemctl enable tarnish.service + ;; + disable) + systemctl disable tarnish.service + ;; + apps) + rot apps get applications | jq -r 'keys | .[]' + ;; + running) + rot apps get runningApplications | jq -r 'keys | .[]' + ;; + paused) + rot apps get pausedApplications | jq -r 'keys | .[]' + ;; + launch | resume) + rot apps get applications \ + | jq -cr ".$2" | sed 's|/codes/eeems/oxide1/||' \ + | xargs -I {} rot --object Application:{} apps call launch + ;; + close) + rot apps get applications \ + | jq -cr ".$2" | sed 's|/codes/eeems/oxide1/||' \ + | xargs -I {} rot --object Application:{} apps call stop + ;; + pause) + rot apps get applications \ + | jq -cr ".$2" | sed 's|/codes/eeems/oxide1/||' \ + | xargs -I {} rot --object Application:{} apps call pause + ;; + *) + echo "Oxide does not support this method" + exit 1 + ;; +esac diff --git a/package/oxide/package b/package/oxide/package index 66a6575e4..9a054a354 100644 --- a/package/oxide/package +++ b/package/oxide/package @@ -4,7 +4,7 @@ pkgnames=(oxide oxide-extra oxide-utils inject_evdev liboxide liboxide-dev libsentry) _oxidever=2.7 -pkgver=$_oxidever-3 +pkgver=$_oxidever-4 _sentryver=0.5.0 timestamp=2023-12-05T04:43:04Z maintainer="Eeems " @@ -15,10 +15,12 @@ image=qt:v3.1 source=( "https://github.com/Eeems-Org/oxide/archive/refs/tags/v$_oxidever.zip" toltec-rm2-override.conf + launcherctl-oxide ) sha256sums=( e1f20fc60ae8edccb941e09c0e61cbfb58f1f8a5f64be98870eb2d079f83316f SKIP + SKIP ) build() { @@ -55,20 +57,26 @@ oxide() { # Task switcher install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/release/opt/bin/corrupt install -D -m 644 -t "$pkgdir"/opt/usr/share/applications "$srcdir"/release/opt/usr/share/applications/codes.eeems.corrupt.oxide + # launcherctl registration + install -D -m 755 -t "$pkgdir"/opt/usr/toltecctl/oxide "$srcdir"/launcherctl-oxide } configure() { systemctl daemon-reload - if ! is-enabled "tarnish.service"; then + + if ! launcherctl is-current-launcher oxide; then echo "" - echo "Run the following command(s) to use $pkgname as your launcher" - how-to-enable "tarnish.service" + echo "Run the following command(s) to use oxide as your launcher" + echo "launcherctl switch-launcher --start oxide" echo "" fi } preremove() { - disable-unit tarnish.service + # Just in case more than one launcher is active, do individual checks + if launcherctl is-active-launcher oxide || launcherctl is-enabled-launcher oxide; then + launcherctl switch-launcher --start xochitl + fi } postremove() { diff --git a/package/rmkit/launcherctl-remux b/package/rmkit/launcherctl-remux new file mode 100755 index 000000000..d0c1e5436 --- /dev/null +++ b/package/rmkit/launcherctl-remux @@ -0,0 +1,167 @@ +#!/bin/bash +set -e +remux_pid() { + systemctl show --no-pager --property MainPID remux.service | sed 's|MainPID=||' +} +remux_ppid() { + grep "PPid:" "/proc/$(remux_pid)/status" | awk '{print $2}' +} +draft_apps() { + find {/opt,}/etc/draft -maxdepth 1 -type f | while read -r file; do + name="$(grep 'name=' "$file" | sed 's|^name=||')" + call="$(grep 'call=' "$file" | sed 's|^call=||')" + echo -e "${name}\t${call}" + done +} +running_remux_apps() { + /opt/libexec/ps-procps-ng --ppid "$(remux_ppid)" -o pid,state,args | tail -n +2 | while read -r info; do + if [[ "$(echo "$info" | awk '{print $2}')" != "$1" ]]; then + continue + fi + pid="$(echo "$info" | awk '{print $1}')" + cmdline="$(echo "$info" | awk '{for (i=3; i<=NF; i++) print $i}')" + draft_apps | while read -r info; do + name="$(echo "$info" | cut -f1)" + if [[ "$name" == "xochitl" ]]; then + if [[ "$(realpath "/proc/${pid}/exe")" == "/usr/bin/xochitl" ]]; then + echo "$name" + break + fi + fi + call="$(echo "$info" | cut -f2)" + if [[ "$cmdline" == "$call" ]]; then + echo "$name" + break + fi + if ! [ -f "$call" ]; then + continue + fi + if [[ "$(realpath "/proc/${pid}/exe")" == "$(realpath "$call")" ]]; then + echo "$name" + break + fi + done + done +} +kill_pid() { + pid="$1" + if [[ "$(awk '{print $3}' "/proc/${pid}/stat")" == "T" ]]; then + kill -CONT "$pid" + fi + kill -TERM "$pid" + # Wait 5s for process to exit + start="$(date +'%s')" + while kill -0 "$pid" 2> /dev/null; do + sleep 0.5 + if [ "$(date +'%s')" -gt $((start + 5)) ]; then + break + fi + done + if kill -0 "$pid" 2> /dev/null; then + # If process is still running, force kill it + kill -KILL "$pid" + fi +} +case "$1" in + is-active) + systemctl is-active --quiet remux.service + ;; + is-enabled) + systemctl is-enabled --quiet remux.service + ;; + logs) + if [ $# -eq 2 ] && [[ "$2" == "-f" ]] || [[ "$2" == "--follow" ]]; then + journalctl --follow --all --unit remux.service + else + journalctl --no-pager --all --unit remux.service + fi + ;; + start) + systemctl start remux.service + ;; + stop) + systemctl stop remux.service + ;; + enable) + systemctl enable remux.service + ;; + disable) + systemctl disable remux.service + ;; + apps) + find {/opt,}/etc/draft -maxdepth 1 -type f | while read -r file; do + grep 'name=' "$file" | sed 's|^name=||' + done + ;; + running) + running_remux_apps S + ;; + paused) + running_remux_apps T + ;; + launch | resume) + echo "launch $2" > /run/remux.api + ;; + close) + draft_apps | while read -r info; do + name="$(echo "$info" | cut -f1)" + if [[ "$name" != "$2" ]]; then + continue + fi + call="$(echo "$info" | cut -f2)" + /opt/libexec/ps-procps-ng --ppid "$(remux_ppid)" -o pid,args | tail -n +2 | while read -r info; do + pid="$(echo "$info" | awk '{print $1}')" + if [[ "$name" == "xochitl" ]]; then + if [[ "$(realpath "/proc/${pid}/exe")" == "/usr/bin/xochitl" ]]; then + kill_pid "$pid" + continue + fi + fi + cmdline="$(echo "$info" | awk '{for (i=2; i<=NF; i++) print $i}')" + if [[ "$cmdline" == "$call" ]]; then + kill_pid "$pid" + continue + fi + if ! [ -f "$call" ]; then + continue + fi + if [[ "$(realpath "/proc/${pid}/exe")" == "$(realpath "$call")" ]]; then + kill_pid "$pid" + fi + done + done + ;; + pause) + draft_apps | while read -r info; do + name="$(echo "$info" | cut -f1)" + if [[ "$name" != "$2" ]]; then + continue + fi + call="$(echo "$info" | cut -f2)" + /opt/libexec/ps-procps-ng --ppid "$(remux_ppid)" -o pid,args | tail -n +2 | while read -r info; do + pid="$(echo "$info" | awk '{print $1}')" + if [[ "$name" == "xochitl" ]]; then + if [[ "$(realpath "/proc/${pid}/exe")" == "/usr/bin/xochitl" ]]; then + kill -STOP "$pid" + continue + fi + fi + cmdline="$(echo "$info" | awk '{for (i=2; i<=NF; i++) print $i}')" + if [[ "$cmdline" == "$call" ]]; then + kill -STOP "$pid" + continue + fi + if ! [ -f "$call" ]; then + continue + fi + if [[ "$(realpath "/proc/${pid}/exe")" == "$(realpath "$call")" ]]; then + kill -STOP "$pid" + fi + done + done + ;; + *) + echo "Remux does not support this method" + exit 1 + ;; +esac diff --git a/package/rmkit/package b/package/rmkit/package index 2b3da328a..4147a0460 100644 --- a/package/rmkit/package +++ b/package/rmkit/package @@ -14,11 +14,13 @@ source=( https://github.com/rmkit-dev/rmkit/archive/7edc291646c4a72b7b8a512205646a9ad6586fd6.zip remux.service genie.service + launcherctl-remux ) sha256sums=( 2861ea61ef272acd0d1d9ec4c80f44ef620be3f8ce58a356fbcbdb27e01dc9e8 SKIP SKIP + SKIP ) build() { @@ -145,27 +147,33 @@ nao() { remux() { pkgdesc="Launcher that supports multi-tasking applications" url="https://rmkit.dev/apps/remux" - pkgver=0.3.0-1 + pkgver=0.3.0-2 section="launchers" + installdepends=(procps-ng-ps) + package() { install -D -m 755 "$srcdir"/src/build/remux "$pkgdir"/opt/bin/remux install -D -m 644 "$srcdir"/remux.service "$pkgdir"/lib/systemd/system/remux.service + install -D -m 755 -t "$pkgdir"/opt/share/launcherctl/"$pkgname" "$srcdir"/launcherctl-remux } configure() { systemctl daemon-reload - if ! is-enabled "$pkgname.service"; then + if ! launcherctl is-current-launcher "$pkgname"; then echo "" echo "Run the following command(s) to use $pkgname as your launcher" - how-to-enable "$pkgname.service" + echo "launcherctl switch-launcher --start $pkgname" echo "" fi } preremove() { - disable-unit "$pkgname.service" + # Just in case more than one launcher is active, do individual checks + if launcherctl is-active-launcher "$pkgname" || launcherctl is-enabled-launcher "$pkgname"; then + launcherctl switch-launcher --start xochitl + fi } postremove() { diff --git a/package/toltec-base/package b/package/toltec-base/package index 324a7ff4a..183cb2995 100644 --- a/package/toltec-base/package +++ b/package/toltec-base/package @@ -6,12 +6,12 @@ archs=(rmall rmallos2 rmallos3 rm1 rm1os2 rm1os3 rm2 rm2os2 rm2os3) pkgnames=(toltec-base) pkgdesc="Metapackage defining the base set of packages in a Toltec install" url=https://toltec-dev.org/ -pkgver=1.3-3 +pkgver=1.3-4 timestamp=2023-12-27T08:30Z section="utils" maintainer="Eeems " license=MIT -installdepends=(toltec-bootstrap toltec-deletions toltec-completion wget-ssl ca-certificates entware-rc) +installdepends=(toltec-bootstrap toltec-deletions toltec-completion launcherctl wget-ssl ca-certificates entware-rc) installdepends_rm1os2=(open-remarkable-shutdown) installdepends_rm1os3=(open-remarkable-shutdown) installdepends_rm2os2=(rm2-suspend-fix) diff --git a/package/toltec-completion/_launcherctl b/package/toltec-completion/_launcherctl new file mode 100644 index 000000000..66deee8ac --- /dev/null +++ b/package/toltec-completion/_launcherctl @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Copyright (c) 2023 The Toltec Contributors +# SPDX-License-Identifier: MIT +# shellcheck disable=SC2016,SC2199,SC2207 + +_launcherctl() { + local cur prev words cword split + _init_completion -s || return + if [[ $cword -eq 1 ]]; then + COMPREPLY=($(compgen -W 'help status logs list-launchers switch-launcher start-launcher stop-launcher list-apps list-running-apps list-paused-apps start-app stop-app pause-app resume-app is-current-launcher is-enabled-launcher is-active-launcher' -- "$cur")) + return + fi + case ${words[1]} in + logs) + if [[ $cword -eq 2 ]]; then + COMPREPLY+=($(compgen -W "--follow" -- "$cur")) + fi + return + ;; + switch-launcher) + if [[ $cword -eq 2 ]]; then + COMPREPLY+=($(compgen -W "--start $(launcherctl list-launchers)" -- "$cur")) + elif [[ $cword -eq 3 ]]; then + COMPREPLY+=($(compgen -W "$(launcherctl list-launchers)" -- "$cur")) + fi + return + ;; + start-app) + if [[ $cword -eq 2 ]]; then + COMPREPLY+=($(compgen -W "$(launcherctl list-apps)" -- "$cur")) + fi + ;; + stop-app | pause-app) + if [[ $cword -eq 2 ]]; then + COMPREPLY+=($(compgen -W "$(launcherctl list-running-apps)" -- "$cur")) + fi + ;; + resume-app) + if [[ $cword -eq 2 ]]; then + COMPREPLY+=($(compgen -W "$(launcherctl list-paused-apps)" -- "$cur")) + fi + ;; + esac +} + +complete -F _launcherctl launcherctl diff --git a/package/toltec-completion/package b/package/toltec-completion/package index 568d37881..698f50c8b 100644 --- a/package/toltec-completion/package +++ b/package/toltec-completion/package @@ -5,7 +5,7 @@ pkgnames=(toltec-completion) pkgdesc="Expands bash-completion with functions for toltec-specific commands" url=https://github.com/toltec-dev/toltec -pkgver=0.4.0-1 +pkgver=0.4.0-2 timestamp=2022-01-23T23:29Z section="utils" maintainer="Linus K. " @@ -15,12 +15,14 @@ installdepends=(bash-completion) source=( _opkg _toltecctl + _launcherctl _rcctl ) sha256sums=( SKIP SKIP SKIP + SKIP ) package() { diff --git a/package/xochitl/launcherctl-xochitl b/package/xochitl/launcherctl-xochitl new file mode 100755 index 000000000..66c90364b --- /dev/null +++ b/package/xochitl/launcherctl-xochitl @@ -0,0 +1,41 @@ +#!/bin/bash +set -e +case "$1" in + is-active) + systemctl is-active --quiet xochitl.service + ;; + is-enabled) + systemctl is-enabled --quiet xochitl.service + ;; + logs) + if [ $# -eq 2 ] && [[ "$2" == "-f" ]] || [[ "$2" == "--follow" ]]; then + journalctl --follow --all --unit xochitl.service + else + journalctl --no-pager --all --unit xochitl.service + fi + ;; + start | launch) + systemctl start xochitl.service + ;; + stop | close) + systemctl stop xochitl.service + ;; + enable) + systemctl enable xochitl.service + ;; + disable) + systemctl disable xochitl.service + ;; + apps) + echo "xochitl" + ;; + running) + if "$0" is-active; then + echo "xochitl" + fi + ;; + *) + echo "Xochitl does not support this method" + exit 1 + ;; +esac diff --git a/package/xochitl/package b/package/xochitl/package index 0db662542..d30110312 100644 --- a/package/xochitl/package +++ b/package/xochitl/package @@ -5,7 +5,7 @@ pkgnames=(xochitl) pkgdesc="Read documents and take notes" url=https://remarkable.com -pkgver=0.0.0-18 +pkgver=0.0.0-19 timestamp=2022-11-07T20:19:57Z section="readers" maintainer="Mattéo Delabre " @@ -25,6 +25,7 @@ source=( toltec-wrapper.conf env-readme manual-sync@.service + launcherctl-xochitl ) sha256sums=( SKIP @@ -35,6 +36,7 @@ sha256sums=( SKIP SKIP SKIP + SKIP ) package() { @@ -51,6 +53,7 @@ package() { install -D -m 644 -t "$pkgdir"/opt/etc/draft "$srcdir"/xochitl.draft install -D -m 644 -t "$pkgdir"/opt/etc/draft/icons "$srcdir"/xochitl.png install -D -m 644 -t "$pkgdir"/opt/usr/share/applications "$srcdir"/xochitl.oxide + install -D -m 755 -t "$pkgdir"/opt/usr/toltecctl/xochitl "$srcdir"/launcherctl-xochitl install -D -m 644 -t "$pkgdir"/etc/systemd/system/xochitl.service.d \ "$srcdir"/toltec-wrapper.conf