9c16837227
For some reason, .* is really taxing for pgrep, but if you remove it it's way faster... % \time -v pgrep -nf '.*clipmenud$' 325286 Command being timed: "pgrep -nf .*clipmenud$" User time (seconds): 0.83 System time (seconds): 0.00 Percent of CPU this job got: 100% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.83 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 7632 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 1418 Voluntary context switches: 1 Involuntary context switches: 3 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 % \time -v pgrep -nf 'clipmenud$' 325286 Command being timed: "pgrep -nf clipmenud$" User time (seconds): 0.04 System time (seconds): 0.00 Percent of CPU this job got: 100% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.04 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 7320 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 1257 Voluntary context switches: 1 Involuntary context switches: 7 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0
28 lines
647 B
Bash
Executable file
28 lines
647 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
if [[ -z $1 ]] || [[ $1 == --help ]] || [[ $1 == -h ]]; then
|
|
cat << 'EOF'
|
|
clipctl provides controls for the clipmenud daemon.
|
|
|
|
You can temporarily disable clip collection without stopping clipmenud entirely
|
|
by running "clipctl disable". You can then reenable with "clipctl enable".
|
|
EOF
|
|
exit 0
|
|
fi
|
|
|
|
_CLIPMENUD_PID=$(pgrep -u "$(id -u)" -nf 'clipmenud$')
|
|
|
|
if [[ -z "$_CLIPMENUD_PID" ]]; then
|
|
echo "clipmenud is not running"
|
|
exit 2
|
|
fi
|
|
|
|
case $1 in
|
|
enable) kill -USR2 "$_CLIPMENUD_PID" ;;
|
|
disable) kill -USR1 "$_CLIPMENUD_PID" ;;
|
|
*)
|
|
printf 'Unknown command: %s\n' "$1"
|
|
exit 1
|
|
;;
|
|
esac
|