handy

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

newsboat-bookmark-script.sh (7437B)


      1 #!/bin/sh
      2 # bookmark-cmd "~/bin/delicious-bookmark.sh"
      3 # https://raw.githubusercontent.com/uriel1998/newsbeuter-dangerzone/master/bookmarks
      4 
      5 
      6 # Use this template to fix up all your ifttt triggers as well... just send via e-mail.
      7 
      8 url="$1"
      9 title="$2"
     10 description="$3"
     11 # is 'feed' valid ?
     12 feed="$4"
     13 
     14 # trimming length of title so it's tweetable!
     15 if [ ${#title} -gt 109 ]; then
     16     short_title=`echo "$title" | awk '{print substr($0,1,110)}'`
     17 else
     18     short_title="$title"
     19 fi
     20 
     21 # Requires a slightly modified version of 
     22 # https://gist.github.com/uriel1998/3310028
     23 # which only returns the shortened URL.
     24 shorturl=`bitly.py "$url"`
     25 
     26 case "$description" in 
     27     [tT][wW]*)
     28         #twitter - requires oysttyer
     29         #https://github.com/oysttyer/oysttyer
     30         szAnswer=`echo "$short_title: $shorturl"`
     31         perl ttytter.pl -silent -status="$szAnswer"
     32     ;;
     33     [Ss][Oo][Cc]*)
     34         #twitter - requires oysttyer
     35         #https://github.com/oysttyer/oysttyer        
     36         #uses this IFTTT script
     37         #https://ifttt.com/applets/112202p-post-your-tweets-to-facebook-when-you-use-a-specific-hashtag
     38         szAnswer=`echo "$short_title: $shorturl #fb"`
     39         perl ttytter.pl -silent -status="$szAnswer"
     40     ;;
     41     [pP][oO][Cc]*)
     42         # I hate dealing with API OAuth for something as simple as adding a freaking link.
     43         # Send to e-mail DONE.
     44         #http://help.getpocket.com/customer/portal/articles/482759
     45         echo "$url" | mutt -s "$short_title" add@getpocket.com
     46         notify-send --icon=notification-network-wireless-full "Sent to Pocket"
     47     ;;
     48     #BUFFER: Send to email using http://bufferapp.com/guides/email
     49     [Bb][uU][Ff]*)
     50         echo "$url" | mutt -s "$short_title" buffer-BLAHBLAHBLAH@to.bufferapp.com
     51         notify-send --icon=notification-network-wireless-full "Mailed to Buffer"
     52     ;;
     53 
     54     #REMEMBER THE MILK: Send to RTM via email: https://www.rememberthemilk.com/services/email/
     55     [Rr][Tt][Mm]*)
     56         echo -e "U: $url\nS: RSS\n-end-" | mutt -s "$short_title" username+abc123@rmilk.com
     57         notify-send --icon=notification-network-wireless-full "Sent to RTM"
     58     ;;
     59     
     60     *) 
     61         # echo "${url}\t${title}" >> ~/bookmarks.txt
     62         # echo "${url}\t${title}" >> ~/.newsboat/newsboat-bookmarks.txt
     63         # echo -e "${url}\t${title}" >> ~/.newsboat/newsboat-bookmarks.txt
     64         # echo -e "${url}\n${title}" >> ~/.newsboat/newsboat-bookmarks.txt
     65         # echo -e "${title}\n${url}\n\n" >> ~/.newsboat/newsboat-bookmarks.txt
     66 	echo -e "${feed}\n${title}\n${url}\n${description}\n\n" >> ~/.newsboat/Newsboat_bookmarks/latest-newsboat-bookmarks.txt
     67         notify-send --icon=notification-network-wireless-full "Saved to URL List"       
     68     ;;
     69 esac
     70 
     71 
     72 
     73 
     74 
     75 # 
     76 # factory
     77 # 
     78 #  #!/bin/sh
     79 #  url="$1"
     80 #  title="$2"
     81 #  description="$3"
     82 #  echo -e "${title}\n<${url}>\n${description}\n\n" >> ~/TODO.rss-bookmarks.txt
     83 
     84 
     85 #
     86 # mail list
     87 #
     88 #     Is there a way to yank the url from an article to the clipboard? At the moment
     89 #     I'm sneaking this functionality in via the `bookmark-plugin.sh
     90 #     This works, but maybe I don't always want to save the info.
     91 #     
     92 #     
     93 #     # factory printf
     94 #     os=$(name)
     95 #     if [[ ${os} == "Darwin" ]]; then
     96 #          printf "%s\t%s\t%s\t%s" \
     97 #              "${url}" \
     98 #              "${title}" \
     99 #              "${description}" \
    100 #              "${feed_title}" >> ~/Nextcloud/bookmarks.txt
    101 #          echo "${url}" | pbcopy
    102 #     fi
    103 #     
    104 #     
    105 #     You can change the `browser` variable to point to the script, open the 
    106 #     article, and reset the variable back afterwards: 
    107 #     
    108 #     macro o set browser "/path/to/your/script.sh"; open-in-browser; set browser "/usr/bin/firefox" 
    109 #     
    110 #     The script should accept the URL as its first argument: 
    111 #     
    112 #     #!/bin/sh 
    113 #     url="$1" 
    114 #     echo "$url" | pbcopy 
    115 #     
    116 #     If you need to access some URL that's *inside* an article, your best bet 
    117 #     is an external URL viewer. I haven't used any such programs, so can't 
    118 #     recommend anything in particular, let alone tell you if any of them 
    119 #     enable you to copy the URL to the clipboard. But you're welcome to try 
    120 #     them out by changing the external-url-viewer setting: 
    121 #     https://newsboat.org/releases/2.14.1/docs/newsboat.html#external-url-viewer 
    122 #     
    123 #     Regards, 
    124 #     Alexander Batischev 
    125 #     
    126 #     
    127 #     
    128 #     
    129 #     
    130 #     
    131 #     
    132 #     
    133 #     I am trying to create a macro that will allow me to remove a url from the urls file.
    134 #     I have tried sed, awk, and grep. 
    135 #     I am able to make them all work outside newsboat but can get them to work when I run the macro.
    136 #     Is the urls file locked while newsboat is running? 
    137 #     Or do I have the syntax wrong?
    138 #     
    139 #     Here's what I have tried. 
    140 #                
    141 #     macro r set browser "sed -i '\|%u|d' /home/pi/snap/newsboat/682/.newsboat/urls"; open-in-browser ; set browser "w3m"; reload-urls 
    142 #                                             
    143 #     macro r set browser "sed -i 's|%u||' /home/pi/snap/newsboat/682/.newsboat/urls"; open-in-browser ; set browser "sed -i '/^$/d' /home/pi/snap/newsboat/682/.newsboat/ur    ls"; open-in-browser ; set browser "w3m"; reload-urls    
    144 #     
    145 #     macro y set browser "sed -i '/^$/d' /home/pi/snap/news    boat/682/.newsboat/urls"; open-in-browser ; set browser "w3m"; reload-urls                                        
    146 #     
    147 #     macro r set browser "awk '!/%u/' /home/pi/snap/newsboat/682/.newsboat/urls > ./temp && mv ./temp /home/pi/snap/newsboat/682/.newsboat/urls"; open-in-browser ; set browser "w3m"; reload-urls                                    
    148 #     
    149 #     macro r set browser "/home/pi/snap/newsboat/682/.newsbo    at/remove_url %u"; open-in-browser ; set browser "w3m"; reload-urls
    150 #     
    151 #     I also tried running these from a bash script without any luck.
    152 #     
    153 #     Any suggestions on how to accomplish this?
    154 #     
    155 #     Thanks
    156 #     
    157 #     ANSWER
    158 #     
    159 #     >macro r set browser "sed -i '\|%u|d' 
    160 #     >/home/pi/snap/newsboat/682/.newsboat/urls"; open-in-browser ; set 
    161 #     >browser "w3m"; reload-urls 
    162 #     
    163 #     This approach is perfectly correct. What trips it is that Newsboat puts 
    164 #     the URL in single quotes, so the command becomes `sed -i 
    165 #     '\|'https://example.com'|d' path`. This clearly won't work. 
    166 #     
    167 #     The easiest workaround I know is to put the command in the script, like 
    168 #     this: 
    169 #     
    170 #         #!/bin/sh 
    171 #     
    172 #         url="$1" 
    173 #         sed -i "\|${url}|d" /home/pi/snap/newsboat/682/.newsboat/urls 
    174 #     
    175 #     Store it in /home/pi/snap/newsboat/682/.newsboat/remove-url, and change 
    176 #     your config as follows: 
    177 #     
    178 #         macro r set browser "/home/pi/snap/newsboat/682/.newsboat/remove-url %u"; open-in-browser ; set browser "w3m"; reload-urls 
    179 #     
    180 #     I tested this, and it works that way. You mention you tried putting the 
    181 #     command in a script already and it didn't work; perhaps your script was 
    182 #     a bit different from mine? 
    183 #     
    184 #     There is a second pitfall to be aware of: you need to reload the feed at 
    185 #     least once for that macro to work. If you don't, Newsboat will pretend 
    186 #     it doesn't know the URL, and will call the script with an empty string 
    187 #     as an argument. 
    188 #     
    189 #     
    190 #     As it turns out, neither of these details are documented. I'll update 
    191 #     the docs now. Sorry you had to learn them the hard way. 
    192 #     
    193 #     
    194 #