-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxcbmanip
More file actions
executable file
·88 lines (74 loc) · 3.66 KB
/
xcbmanip
File metadata and controls
executable file
·88 lines (74 loc) · 3.66 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# X Clipboard Manipulation
# Grab the clipboard contents
XCBC="$(xclip -o -selection c)"
# For comparisons, compare in lowercase
LCCB="${XCBC,,}"
XMSG="none"
if [ "${XCBC:0:15}" == "https://goo.gl/" ]; then
# Discard everything before the final slash
CODE="${XCBC##*/}"
# Put what we want into the clipboard
echo -n "=HYPERLINK(\"${XCBC}\",\"${CODE}\")" | xclip -i -selection c
XMSG="Converted Google Short URL to Google Sheets HYPERLINK"
fi
if [ "${LCCB:0:19}" == "vocaloidprojectdiva" ]; then
# Put spaces where they belong
for SPACEME in VOCALOID Vocaloid ProjectDIVA ProjectDiva 初音ミク 巡音ルカ 鏡音レン 鏡音リン Meiko MEIKO Kaito KAITO; do
XCBC="${XCBC/${SPACEME}/${SPACEME} }"
done
# Fix EN-vs-JA capitalization
XCBC="${XCBC/Vocaloid/VOCALOID}"
XCBC="${XCBC/ProjectDiva/ProjectDIVA}"
XCBC="${XCBC/Meiko/MEIKO}"
XCBC="${XCBC/Kaito/KAITO}"
# Put what we want into the clipboard
echo -n "${XCBC}" | xclip -i -selection c
XMSG="Spaced Nico Nico Douga Tags"
fi
if [ "${XCBC: -1:1}" == ' ' ]; then
echo -n "$(xclip -o -seclection c)" | sed 's|^"||g;s|"\t*||g;s|\t*$||g;' | sed ':a;N;$!ba;s/ <br>$//g' | xclip -i -selection c
XMSG="Fixed Google Sheets Copy-Paste"
fi
if [[ "${XCBC}" =~ ^https://youtu\.be/.{11}$ ]]; then
echo -n "$(xclip -o -selection c)" | sed 's|^https://youtu\.be/||g' | xclip -i -selection c
XMSG="Extracted YouTube Video ID From Hyperlink."
elif [[ "${XCBC}" =~ ^https://www\.youtube\.com/watch\?.*$ ]]; then
echo -n "$(xclip -o -selection c)" | sed 's|.*v=\(.\{11\}\).*|\1|g' | xclip -i -selection c
XMSG="Extracted YouTube Video ID From Hyperlink."
elif [[ "${XCBC}" =~ ^https://www\.youtube\.com/edit\?.*$ ]]; then
echo -n "$(xclip -o -selection c)" | sed 's|.*video_id=\(.\{11\}\).*|\1|g' | xclip -i -selection c
XMSG="Extracted YouTube Video ID From Hyperlink."
fi
if [[ "${XCBC}" =~ ^http://nico\.ms/[ns1][m0-9][0-9]{6,8}$ ]]; then
echo -n "$(xclip -o -selection c)" | sed 's|^https://nico\.ms/||g' | xclip -i -selection c
XMSG="Extracted Nico Video ID From Hyperlink"
elif [[ "${XCBC}" =~ ^http://www\.nicovideo\.jp/watch/[ns1][m0-9][0-9]{6,8} ]]; then
echo -n "$(xclip -o -selection c)" | sed 's|.*/watch/\([ns1][m0-9][0-9]\{6,8\}\).*|\1|g' | xclip -i -selection c
XMSG="Extracted Nico Video ID From Hyperlink"
fi
if [[ ${XCBC} =~ ^.*Project\ Diva\ .*\ -\ .*\ -\ .*$ ]]; then
echo -n "$(xclip -o -selection c)" | sed 's| - | — |g;s| \(.*\) — \([0-9]\{2,3\}\.[0-9]\{2\}\%\) Perfect| \1 Perfect (\2)|g' | xclip -i -selection c
XMSG="Fixed Old Project Diva YouTube Title"
fi
if [[ ${XCBC} =~ ^.*Project\ Diva\ .*\ —\ .*\ —\ .*$ ]]; then
echo -n "$(xclip -o -selection c)" | sed 's/Project Diva \([[:alnum:]]\+ \{0,1\}[[:alnum:]]*\) — /【Project Diva \1】/g;s/】\(.*\) — /】「\1」/g' | xclip -i -selection c
XMSG="Converted YouTube Title From EN to JA."
fi
if [[ ${XCBC} =~ ^\#.*-.* ]]; then
echo -n "$(xclip -o -selection c)" | sed 's/-/_/g' | xclip -i -selection c
XMSG="Converted dashed hastags to underscored hashtags"
fi
PDGL=(初音ミク-ProjectDIVA- 初音ミク-ProjectDIVA-2nd 初音ミク-ProjectDIVA-extend 初音ミク-ProjectDIVA-F 初音ミク-ProjectDIVA-F2nd 初音ミク-ProjectDIVA-X 'ProjectDivaArcade Future_Tone' 初音ミク-ProjectDIVA-)
set -x
if [ "${XMSG}" = "none" ]; then
for (( lcv=0; lcv<$(( ${#PDGL[@]} - 1 )); lcv++ )) {
if [[ ${XCBC} =~ ${PDGL[${lcv}]}$ ]]; then
echo -n "$(xclip -o -selection c)" | sed "s/${PDGL[${lcv}]}/${PDGL[$(( ${lcv} + 1 ))]}/g" | xclip -i -selection c
XMSG="Converted ${PDGL[${lcv}]} to ${PDGL[ $(( ${lcv} + 1 ))]}"
break
fi
}
fi
set +x
Xdialog --title "X Clipboard Manipulation" --msgbox "${XMSG}" 0 0