-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcharpickerprint.sh
executable file
·55 lines (43 loc) · 1.19 KB
/
charpickerprint.sh
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
#!/bin/bash
#
# Based on work by /~https://github.com/mbfraga
# This version modified by Leonora Tindall <nora@nora.codes>
# Released under the GNU GPL v3.0
theme="arthur-c.rasi"
character_list_rofi="special_character_list.rofi"
character_list_chars="special_character_list.symbols"
user_theme=~/.config/charpicker/theme.rasi
if [ -f "$user_theme" ]; then
theme="$user_theme"
fi
start_rofi () {
rofi -dmenu -i -sync -theme "$theme" -p "sym:" -format d
}
compile () {
./compile.sh
}
cd "$(dirname "$0")" || exit 1
# compile rofi lines and character files if needed
if [ ! -f .compiled-sha1 ]; then
compile
else
if [ "$(sha1sum < ./effective_special_character_list.sh)" != "$(cat .compiled-sha1)" ]; then
compile
fi
fi
# check if rofi is installed
if ! (command -v rofi &>/dev/null); then
echo "rofi is not installed; aborting"
exit 2
fi
# make the user select an entry
selected_row=$(start_rofi < "$character_list_rofi")
if [ $? -ne 0 ]; then
exit 1
fi
# select the corresponding symbol
selected_symbol="$(sed -n ${selected_row}p "$character_list_chars")"
# trim trailing whitespaces
selected_symbol="${selected_symbol// }"
# print symbol
echo -n "$selected_symbol"