Files
fish-config/functions/wake-lock.fish
T
rootiest 500dd8a735 feat(help): standardize colored --help output across functions
Add the established c_head/c_cmd/c_flag/c_dim/c_arg color scheme to
--help (or usage-on-error) output in play-media and 13 other functions
that lacked it or used an ad hoc scheme: bkg, detach, replay, p, y,
spark, wake-lock, open-url, repo-open, dng2avif, dockup, fish-deps
(__fish_deps_help), and scrub.

Also tweak the standard itself:
- c_cmd now uses plain `set_color --bold` instead of `--bold white`,
  so the command name adapts to the terminal's foreground instead of
  forcing white text that washes out on light-background themes.
  Applied across all functions already using the pattern.
- jobrunner's reset variable renamed from c_rst to c_reset to match
  the naming used everywhere else.
2026-08-22 00:19:43 -04:00

40 lines
1.2 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# CATEGORY
# 14-miscellaneous
#
# SYNOPSIS
# wake-lock <command> [args...]
#
# DESCRIPTION
# Runs a command under systemd-inhibit to prevent the system from idling
# or sleeping for the duration of the command.
#
# ARGUMENTS
# command Command to run with sleep inhibition active
# args... Arguments forwarded to the command
#
# EXIT STATUS
# 0 Command ran and completed
# 1 No command provided
#
# EXAMPLE
# wake-lock rsync -avz src/ dest/
function wake-lock --description 'Run a command while inhibiting system sleep'
if test (count $argv) -eq 0
set -l c_head (set_color --bold cyan)
set -l c_cmd (set_color --bold)
set -l c_arg (set_color cyan)
set -l c_reset (set_color normal)
echo "$c_head""Usage:$c_reset $c_cmd""wake-lock$c_reset $c_arg""[command] [args...]$c_reset"
return 1
end
echo "Running '$argv' with sleep inhibition active..."
# --what=idle:sleep prevents the system from auto-sleeping or being suspended
# --who identifies your function in 'systemd-inhibit --list'
systemd-inhibit --why="Manual task inhibition" --who="wake-lock" --what=idle:sleep $argv
end