Skip to content

Commit

Permalink
desktop.media.streamdump: fix time/cg-prefix arg parsing before others
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-fg committed Jun 5, 2024
1 parent 72c142e commit 6aed7e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions desktop/media/streamdump
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ usage() {
grep -Pq '(^| -)(h|-help)( |$)' <<< "$*" && usage
set -eo pipefail

[[ "${1:0:1}" != + ]] || { cg_arg=${1:1}; shift; }

fmt=$slink_fmt cmd=( streamlink "${slink_opts[@]}" )
while [[ "$#" -gt 2 ]]; do
arg=$1; shift
Expand All @@ -46,10 +48,12 @@ url=$1 fn=$2
scope=streamdump.$(echo -n "$fn" | md5sum | cut -b-5)

# Main loop always runs within known scope, to be able to terminate it cleanly
[[ "$1" != +X ]] && shift || {
[[ "$cg_arg" = X ]] || {
systemctl -q --user stop "$scope".scope &>/dev/null ||:
[[ "${1:0:1}" != + ]] || { shift; systemd-run -qGd --user \
--on-active="${1:1}" -u $scope -- systemctl --user stop $scope.scope; }
[[ -z "$cg_arg" ]] || {
systemctl -q --user stop "$scope".timer &>/dev/null ||:
systemd-run -qGd --user \
--on-active="$cg_arg" -u $scope -- systemctl --user stop $scope.scope; }
systemd-run -qGd --user --slice-inherit --scope -u $scope -- "$0" +X "$@"; exit; }

n=0
Expand Down

0 comments on commit 6aed7e9

Please sign in to comment.