Last active
May 3, 2024 21:50
-
-
Save tyjak/6489320d1def15b182b86bf29f1d1b73 to your computer and use it in GitHub Desktop.
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
#!/bin/zsh | |
# Export title, link and extraxt to a gmi file | |
# GistID: 6489320d1def15b182b86bf29f1d1b73 | |
id=$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}') | |
name=$(xprop -id $id | awk '/_NET_WM_NAME/{$1=$2="";print}' | cut -d'"' -f2) | |
FILE_NOTE=${GMI_FILE_NOTE:-~/sdf/gopher/notes-de-lectures.gmi} | |
#FILE_NOTE=/tmp/test.gmi | |
TITRE=${1:-$name} | |
TEXT=${2:-$(xsel -o)} | |
LINK=${3:-NO-LINK-PROVIDED} | |
FINAL_OUTPUT="${TITRE}\n> ${TEXT}\n=> ${LINK} source consultée le $(date +%d.%m.%Y)" | |
echo $FINAL_OUTPUT | |
echo $FILE_NOTE | |
/bin/sed -i "5i## ${TITRE}\n> ${TEXT}\n=> ${LINK} source consultée le $(date +%d.%m.%Y)\n" $FILE_NOTE && (\ | |
/bin/echo "Note créée" && \ | |
notify-send "$TITRE" "$TEXT" \ | |
)||( \ | |
echo "Note non publiée" && \ | |
notify-send "NO DATA" "$FINAL_OUTPUT" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment