simplify seq-command module
This commit is contained in:
parent
c8d0d05a12
commit
e1904b85d9
1 changed files with 1 additions and 11 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
let
|
let
|
||||||
seqCommandScript = pkgs.writeShellScriptBin "seq-command" ''
|
seqCommandScript = pkgs.writeShellScriptBin "seq-command" ''
|
||||||
gap=0
|
gap=0
|
||||||
service=false
|
|
||||||
file=""
|
file=""
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|
@ -12,10 +11,6 @@ let
|
||||||
gap="$2"
|
gap="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--service)
|
|
||||||
service=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
file="$1"
|
file="$1"
|
||||||
shift
|
shift
|
||||||
|
|
@ -26,11 +21,10 @@ let
|
||||||
if [[ -z "$file" || "$gap" -eq 0 ]]; then
|
if [[ -z "$file" || "$gap" -eq 0 ]]; then
|
||||||
echo "seq-command - Execute commands from a file sequentially with gaps"
|
echo "seq-command - Execute commands from a file sequentially with gaps"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Usage: seq-command --gap <minutes> [--service] <commands-file>"
|
echo "Usage: seq-command --gap <minutes> <commands-file>"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --gap <minutes> Wait time between command executions"
|
echo " --gap <minutes> Wait time between command executions"
|
||||||
echo " --service Run as a background systemd user service"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "The commands file is treated as a FIFO queue - each line is removed after execution."
|
echo "The commands file is treated as a FIFO queue - each line is removed after execution."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -43,10 +37,6 @@ let
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $service; then
|
|
||||||
exec systemd-run --user --unit="seq-command-$(date +%s)" seq-command --gap "$gap" "$file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
gap_seconds=$((gap * 60))
|
gap_seconds=$((gap * 60))
|
||||||
|
|
||||||
while [[ -s "$file" ]]; do
|
while [[ -s "$file" ]]; do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue