Modify system menu
This commit is contained in:
@ -8,9 +8,8 @@ function is-desktop-p {
|
|||||||
! is-laptop-p
|
! is-laptop-p
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $(is-desktop-p)
|
systemctl --user --quiet is-active swayidle.service \
|
||||||
|
&& swayidle_state="Enabled" || swayidle_state="Disabled"
|
||||||
pgrep swayidle && swayidle_state="Enabled" || swayidle_state="Disabled"
|
|
||||||
|
|
||||||
# Format: label action condition
|
# Format: label action condition
|
||||||
local entries=('Select system sound output' 'select-sound-output.sh' 'true'
|
local entries=('Select system sound output' 'select-sound-output.sh' 'true'
|
||||||
@ -32,7 +31,8 @@ for ((i = 1; i <= ${#entries}; i+=3)); do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
local scripts_dir="$(dirname "$(realpath "${0}")")"
|
local scripts_dir="${1:h:P}"
|
||||||
|
echo ${scripts_dir}
|
||||||
choice="$(printf '%s\n' ${entry_array} | fuzzel --index -d)"
|
choice="$(printf '%s\n' ${entry_array} | fuzzel --index -d)"
|
||||||
|
|
||||||
(( ${?} != 0 )) && exit
|
(( ${?} != 0 )) && exit
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
local CACHE_PATH="${HOME}/.cache/system-sleep-menu"
|
let is_active=0
|
||||||
|
systemctl --user --quiet is-active swayidle.service && is_active=1
|
||||||
|
|
||||||
pgrep swayidle >/dev/null 2>&1 \
|
local swayidle_state
|
||||||
&& swayidle_state="Enabled" \
|
(( is_active )) && swayidle_state='Enabled' || swayidle_state='Disabled'
|
||||||
|| swayidle_state="Disabled"
|
|
||||||
|
|
||||||
choice="$(fuzzel --index -d -p "Cur: ${swayidle_state} > " <<'EOF'
|
choice="$(fuzzel --index -d -p "Cur: ${swayidle_state} > " <<'EOF'
|
||||||
Enable
|
Enable
|
||||||
@ -16,25 +16,10 @@ EOF
|
|||||||
|
|
||||||
case "${choice}" in
|
case "${choice}" in
|
||||||
0)
|
0)
|
||||||
if [[ "${swayidle_state}" == 'Disabled' ]]; then
|
systemctl --user start swayidle.service
|
||||||
local cmd_cache=(${(0)"$(<"${CACHE_PATH}")"})
|
|
||||||
{
|
|
||||||
set -x
|
|
||||||
cd "${cmd_cache[1]}"
|
|
||||||
exec ${=${cmd_cache[2]}}
|
|
||||||
} &
|
|
||||||
disown
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
pgrep_output=(${(ps: :)"$(pgrep -fa swayidle)"})
|
systemctl --user stop swayidle.service
|
||||||
if [[ "${swayidle_state}" = 'Enabled' ]]; then
|
|
||||||
local si_pid="${pgrep_output[1]}"
|
|
||||||
local si_pwd="$(readlink "/proc/${si_pid}/cwd")"
|
|
||||||
local si_cmd="${pgrep_output:1}"
|
|
||||||
printf '%s\0%s' "${si_pwd}" "${si_cmd}" >"${CACHE_PATH}"
|
|
||||||
pkill swayidle
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user