blob: 9d48a207418843ec7a678377600f533c6a915feb (
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
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
|
#!/bin/bash
search_web() {
QUERY=$(tac ~/.config/surf/search.txt | sort -u | dmenu -l 20 -p "Search DuckDuckGo: ")
SEARCH=$(echo $QUERY | sed 's/ /+/g; s/-e//')
URL="duckduckgo.com/?q=$SEARCH"
CMD="$sarc_browser $URL"
#CMD="firejail --noprofile --hosts-file=~/.config/surf/ads.txt tabbed -dn tabbed-surf -r 2 surf -e '' $URL"
if [[ -z "$SEARCH" ]]; then
exit
else
# saves search to history
echo $QUERY | sed 's/-e//' >> ~/.config/surf/search.txt
$CMD
fi
}
goto_website() {
URL=$(cat ~/.config/surf/history.txt | sed 's/^[^ *]* //; s/-e//' | sort -u | dmenu -p "Enter a URL: ")
POSTURL=$(echo $URL | sed 's/-e//; s/reddit.com/old.reddit.com/')
CMD="$sarc_browser $POSTURL"
#CMD="firejail --noprofile --hosts-file=~/.config/surf/ads.txt tabbed -dn tabbed-surf -r 2 surf -e '' $POSTURL"
if [[ -z "$URL" ]]; then
exit
else
# saves url to history
echo $(echo $URL | sed 's/-e//') >> ~/.config/surf/history.txt
$CMD
fi
}
get_unicode() {
# The famous "get a menu of emojis to copy" script.
# Get user selection via dmenu from emoji file.
chosen=$(cut -d ';' -f1 ~/.local/share/larbs/emoji | dmenu -i -l 30 | sed "s/ .*//")
# Exit if none chosen.
[ -z "$chosen" ] && exit
# If you run this command with an argument, it will automatically insert the
# character. Otherwise, show a message that the emoji has been copied.
if [ -n "$1" ]; then
xdotool type "$chosen"
else
printf "$chosen" | xclip -selection clipboard
notify-send "'$chosen' copied to clipboard." &
fi
}
power() {
case "$(printf "🔃 reboot\n🖥️shutdown\n" | dmenu -i -p 'Power: ')" in
'🔃 reboot') sudo reboot ;;
'🖥️shutdown') sudo poweroff ;;
*) exit 1 ;;
esac
}
redshift_run() {
redshift -l $(curl -s "https://location.services.mozilla.com/v1/geolocate?key=geoclue" | jq -r '"\(.location.lat):\(.location.lng)"')
}
case $1 in
--get_weather)
rm -rf ~/.cache/weather_report
curl wttr.in > ~/.cache/weather_report
$sarc_terminal less -Srf ~/.cache/weather_report;;
--search_web)
search_web;;
--redshift)
redshift_run;;
--unicode) get_unicode;;
--power) power;;
--goto-website) goto_website;;
esac
|