Last active
May 29, 2026 01:05
-
-
Save dewomser/f9c070af7371211362afde5b9d12d6d6 to your computer and use it in GitHub Desktop.
Toot a screenshot from website. Grep title and description and post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/bash | |
| #/usr/bin/import "$HOME"/bin/toot.png | |
| cd "$HOME"/bin/ | |
| # Take URL as argument | |
| url="$1" | |
| # Fetch HTML and extract title and description from head | |
| html=$(curl -s "$url") | |
| # Extract title | |
| title=$(echo "$html" | grep -oP '(?<=<title>).*?(?=</title>)' | head -1) | |
| # Extract description from meta tag | |
| description=$(echo "$html" | grep -oP '(?<=<meta name="description" content=")[^"]*' | head -1) | |
| # Strip remaining HTML tags if any | |
| title=$(echo "$title" | sed 's/<[^>]*>//g') | |
| description=$(echo "$description" | sed 's/<[^>]*>//g') | |
| # Create variable with newline after title | |
| page_info="${title} | |
| ${description} | |
| ${url}" | |
| # Display the result | |
| # echo "$page_info" | |
| spectacle -b -r -o "$HOME"/bin/toot.png | |
| wait | |
| a="$(/usr/bin/kdialog --textinputbox "Dialog-Tooter" "$page_info" )" | |
| if [[ $? = 0 ]]; then | |
| # echo "$a" | |
| toot post "$a" -m "$HOME/bin/toot.png" | |
| exit | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment