aboutsummaryrefslogtreecommitdiff
path: root/dmenuDic.sh
blob: 56c9301e4f46df719961bf37f93eafc0929d7b0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# Selects a word from a dictionary with the help of dmenu and copies it to clipboard.

dicES="$CONFIG_DIC_ES"
dicEN="$CONFIG_DIC_EN"
dicPL="$CONFIG_DIC_PL"
lines=25
dict="$(printf "EN\nES\nPL" | dmenu -l "$lines" -p "Choose a dictionary:")"
if [ "$dict" = "ES" ]; then
	[ ! -f "$dicES" ] && dunstify "ES dic file ($dicES) does not exist." && exit 0
	word="$(dmenu -l "$lines" -p "Elige una palabra:" < "$dicES" )"
fi
if [ "$dict" = "EN" ]; then
	[ ! -f "$dicEN" ] && dunstify "EN dic file ($dicEN) does not exist." && exit 0
	word="$(dmenu -l "$lines" -p "Choose a word:" < "$dicEN")"
fi
if [ "$dict" = "PL" ]; then
	[ ! -f "$dicPL" ] && dunstify "PL dic file ($dicPL) does not exist." && exit 0
	word="$(dmenu -l "$lines" -p "Wybierz słowo:" <  "$dicPL")"
fi
[ "$word" ] || exit 0
echo "$word" | tr -d '\n' | xsel -bi
dunstify -t 2000 "Written [$word] into clipboard."