Skip to content

Instantly share code, notes, and snippets.

@LevitatingBusinessMan
Last active July 19, 2023 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LevitatingBusinessMan/5977867a040d825f46bf2735ec911f9b to your computer and use it in GitHub Desktop.
Save LevitatingBusinessMan/5977867a040d825f46bf2735ec911f9b to your computer and use it in GitHub Desktop.
Synonym of the day
#!/usr/bin/ruby
require 'net/http'
body = Net::HTTP.get(URI("https://www.thesaurus.com/e/synonym-of-the-day/"))
r = /<a.*href="https:\/\/www\.thesaurus\.com\/browse\/.+".*>(\S+)<\/a>\s*is another word for\s*<a.*href="https:\/\/www\.thesaurus\.com\/browse\/.+".*>\s*(\S+)\s*<\/a>\s*<\/h2>/
firstword, secondword = r.match(body).captures
system("{
ACTION=$(dunstify --action='open,Goto thesaurus' '#{firstword} is a synonym of #{secondword}' 'Synonym of the day')
if [[ $ACTION == 'open' ]]; then
xdg-open 'https://www.thesaurus.com/e/synonym-of-the-day/'
fi
} &")
[Unit]
Description=Give synonym of the day message
[Service]
Type=forking
ExecStart=/home/rein/scripts/synonym.rb
[Unit]
Description=Give a daily synonym of the day message
[Timer]
OnCalendar=*-*-* 8:00:00
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment