-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathclip
More file actions
executable file
·63 lines (54 loc) · 1.59 KB
/
Copy pathclip
File metadata and controls
executable file
·63 lines (54 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/sh
# @author nate zhou
# @since 2025,2026
# clipboard manager for Wayland and X
# @depends wmenu dmenu(xorg) wl-copy cliphist clipmenu(xorg)
# This script has completions: `.config/{z,ba}sh/completions/_scripts.{z,ba}sh`
usage() {
cat << _EOF_
USAGE
$(basename $0) [OPTION]
clipboard manager for Wayland and X
without any options, open the dynamic menu to choose a history entry
OPTIONS
-w,--wipe wipe the current session's clipboard history,
cliphist in Wayland, climenu in X
-h,--help print this usage manual
_EOF_
exit 0
}
set_variables() {
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
menu="${HOME}/.local/bin/wmenu-color"
wipe_cmd="cliphist wipe"
elif [ -n "$XAUTHORITY" ]; then
menu="dmenu"
wipe_cmd="rm -rf ${XDG_RUNTIME_DIR}/clipmenu.*.*/*"
fi
}
wipe_history() {
set_variables
choice="$(printf "no\nyes" \
| $menu -p "$(basename $0): wipe clipboard history?")"
if [ "$choice" = "yes" ]; then
notify-send -u low -r 199 "$(basename $0)" "Clipboard wiped"
$wipe_cmd
else
notify-send -u low -r 199 "$(basename $0)" "Aboarted";
exit 0
fi
}
open_clipboard() {
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
cliphist list | wmenu-color -p "$(basename $0)" -l 6 \
| cliphist decode \
| wl-copy
elif [ -n "$XAUTHORITY" ]; then
clipmenu
fi
}
[ -z "$1" ] && open_clipboard
case "$1" in
-w|--wipe) wipe_history ;;
*) usage ;;
esac