Compare commits
3 Commits
2edfb81c35
...
a557035b41
Author | SHA1 | Date |
---|---|---|
cho | a557035b41 | |
cho | 6203f3833a | |
cho | 2f977782b5 |
|
@ -0,0 +1,27 @@
|
|||
|
||||
[Default Applications]
|
||||
|
||||
# xdg-open will use these settings to determine how to open filetypes.
|
||||
# These .desktop entries can also be seen and changed in ~/.local/share/applications/
|
||||
|
||||
text/x-shellscript=text.desktop;
|
||||
x-scheme-handler/magnet=torrent.desktop;
|
||||
application/x-bittorrent=torrent.desktop;
|
||||
x-scheme-handler/mailto=mail.desktop;
|
||||
text/plain=text.desktop;
|
||||
application/postscript=pdf.desktop;
|
||||
application/pdf=pdf.desktop;
|
||||
application/vnd.comicbook+zip=pdf.desktop;
|
||||
application/vnd.comicbook-rar=pdf.desktop;
|
||||
image/png=img.desktop;
|
||||
image/jpeg=img.desktop;
|
||||
image/gif=img.desktop;
|
||||
application/rss+xml=rss.desktop
|
||||
video/x-matroska=video.desktop
|
||||
video/mp4=video.desktop
|
||||
x-scheme-handler/lbry=lbry.desktop
|
||||
inode/directory=file.desktop
|
||||
|
||||
# other
|
||||
x-scheme-handler/https=librewolf.desktop;
|
||||
x-scheme-handler/http=librewolf.desktop;
|
|
@ -7,8 +7,8 @@ bgaloc="${XDG_DATA_HOME:-$HOME/.local/share}/bga"
|
|||
|
||||
trueloc="$(readlink -f "$1")" &&
|
||||
case "$(file --mime-type -b "$trueloc")" in
|
||||
video/* ) ifinstalled mpvpaper && ln -sf "$trueloc" "$bgaloc" && notify-send -i "$bgaloc" "Changing wallpaper..." ;;
|
||||
image/gif ) ifinstalled mpvpaper && ln -sf "$trueloc" "$bgaloc" && ln -sf "$trueloc" "$bgloc" && notify-send -i "$bgaloc" "Changing wallpaper..." ;;
|
||||
video/* ) mpvpaper && ln -sf "$trueloc" "$bgaloc" && notify-send -i "$bgaloc" "Changing wallpaper..." ;;
|
||||
image/gif ) mpvpaper && ln -sf "$trueloc" "$bgaloc" && ln -sf "$trueloc" "$bgloc" && notify-send -i "$bgaloc" "Changing wallpaper..." ;;
|
||||
image/* ) ln -sf "$trueloc" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..."
|
||||
if [[ -f "$bgaloc" ]]; then
|
||||
rm $bgaloc
|
||||
|
|
|
@ -1,18 +1,119 @@
|
|||
#!/bin/sh
|
||||
# derived from yt-id (https://codeberg.org/Denshi/Scripts) and rssadd (https://github.com/lukesmithxyz/voidrice)
|
||||
# requirements: `pup` for parsing html
|
||||
|
||||
if echo "$1" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ; then
|
||||
url="$1"
|
||||
## kill early
|
||||
nothing() {
|
||||
[ -z "$1" ] && printf "Usage: rssadd [RSSURL | YTURL | @Username | XMLFILE | --file FILE | --scan WEBPAGE ]\n" && exit 0
|
||||
}
|
||||
nothing "$1"
|
||||
|
||||
say() {
|
||||
printf "$1 \e[1;34m$2\e[0m\n"
|
||||
}
|
||||
|
||||
add_rss() {
|
||||
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
|
||||
if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then
|
||||
say "You already have this RSS feed." "$url"
|
||||
else
|
||||
echo "$url" >> "$RSSFILE" && say "RSS feed added." "$url"
|
||||
fi
|
||||
}
|
||||
|
||||
get_yt_rss() {
|
||||
BASEURL="https://www.youtube.com/feeds/videos.xml?channel_id="
|
||||
# invidious
|
||||
# BASEURL="https://vid.puffyan.us/feed/channel/"
|
||||
# BASEURL="https://invidious.snopyta.org/feed/channel/"
|
||||
# BASEURL="https://invidious.kavin.rocks/feed/channel/"
|
||||
# BASEURL="https://inv.riverside.rocks/feed/channel/"
|
||||
URL=$url
|
||||
curl -Ls "$URL" > /dev/null || URL="https://www.youtube.com/$URL"
|
||||
# Actually getting the ID
|
||||
ID="$(curl -Ls "$URL" | grep -o -P '.{0,0}channel_id.{0,25}' | sed '$!d' | cut -c 12-35)"
|
||||
[ -z "$ID" ] && say "Channel not found." && exit 1
|
||||
#printf "%s\n" $BASEURL$ID
|
||||
url="$BASEURL$ID"
|
||||
}
|
||||
|
||||
# WIP
|
||||
find_rss() {
|
||||
echo "$url" | grep -Pq "(http|https)://" || url="https://$url"
|
||||
address="$(echo "$url" | sed 's/\/$//')"
|
||||
#domain="$(echo "$url" | grep -Po '(http://|https://)(?:[^./]+[.])*[^\./]*\.[^\./]*(?=/)')"
|
||||
domain="$(echo "$url" | grep -Po '(http://|https://)(?:[^./]+[.])*[^\./]*\.[^\./]*')"
|
||||
read atom < <(curl -Ls "$url" | pup 'link[href][type*="atom+xml"] attr{href}')
|
||||
read rss < <(curl -Ls "$url" | pup 'link[href][type*="rss+xml"] attr{href}')
|
||||
[ -n "$atom" ] && url="$atom"
|
||||
[ -n "$rss" ] && url="$rss"
|
||||
[ -z "$atom" ] && [ -z "$rss" ] && say "RSS not found." "$url" && exit 1
|
||||
if echo "$url" | grep -q '^/' ; then
|
||||
location="$(echo "$url" | sed 's/^\///')"
|
||||
url="$domain/$location"
|
||||
fi
|
||||
echo "$url" | grep -Pq "(http|https)://" || url="$address/$url"
|
||||
}
|
||||
|
||||
# WIP
|
||||
find_fedi_rss() {
|
||||
echo "$handle" | grep "^@.*@*\.*" || say "not a handle" "$url" && exit 1
|
||||
|
||||
}
|
||||
|
||||
add_yt_rss() {
|
||||
get_yt_rss
|
||||
add_rss
|
||||
}
|
||||
|
||||
execute_command() {
|
||||
if echo "$url" | grep -q "^https://www.youtube.com/feeds/videos.xml?*" ; then
|
||||
add_rss
|
||||
elif echo "$url" | grep -q "^https://www.youtube.com/*" ; then
|
||||
add_yt_rss
|
||||
elif echo "$url" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ; then
|
||||
add_rss
|
||||
elif echo "$url" | grep -q "^@.*" ; then
|
||||
add_yt_rss
|
||||
else
|
||||
url="$(grep -Eom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$1" |
|
||||
grep -o "https?://[^\" ]")"
|
||||
|
||||
echo "$url" | grep -q "https*://\S\+\.[A-Za-z]\+\S*" ||
|
||||
notify-send "That doesn't look like a full URL." && exit 1
|
||||
url="$(grep -sEom1 '<[^>]+(rel="self"|application/[a-z]+\+xml)[^>]+>' "$url" | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*")"
|
||||
echo "$url" | grep -Eq "(http|https)://[a-zA-Z0-9./?=_%:-]*" && add_rss ||
|
||||
say "That doesn't look like a full URL." "$url"
|
||||
#TODO be more verbose
|
||||
fi
|
||||
}
|
||||
|
||||
RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
|
||||
if awk '{print $1}' "$RSSFILE" | grep "^$url$" >/dev/null; then
|
||||
notify-send "You already have this RSS feed."
|
||||
else
|
||||
echo "$url" >> "$RSSFILE" && notify-send "RSS feed added."
|
||||
fi
|
||||
execute_loop() {
|
||||
url="$1" && execute_command
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
printf "Usage: rssadd [RSSURL | YTURL | @Username | XMLFILE | --file FILE | --scan WEBPAGE ]
|
||||
|
||||
USAGE
|
||||
-s, --scan
|
||||
scan webpages for rss or atom links.
|
||||
format can be a domain name or http/https links
|
||||
--file
|
||||
input from file seperated with lines\n"
|
||||
exit 0
|
||||
;;
|
||||
-s|--scan)
|
||||
url="$2"
|
||||
nothing "$url"
|
||||
find_rss
|
||||
execute_command
|
||||
exit 0
|
||||
;;
|
||||
--file)
|
||||
nothing "$2"
|
||||
while IFS= read -r line; do
|
||||
execute_loop "$line"
|
||||
done < "$2"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
url="$1"
|
||||
execute_command
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=File Manager
|
||||
Exec=/usr/bin/foot -e lf %u
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Image viewer
|
||||
Exec=/usr/bin/nsxiv -a %f
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Mail
|
||||
Exec=/usr/bin/foot -e neomutt %u
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=PDF reader
|
||||
Exec=/usr/bin/zathura %u
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=RSS feed addition
|
||||
Exec=/usr/bin/env rssadd %U
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Text editor
|
||||
Exec=/usr/bin/foot -e nvim %u
|
|
@ -0,0 +1,5 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Torrent
|
||||
#Exec=/usr/bin/env transadd %U
|
||||
Exec=deluge-gtk %U
|
|
@ -0,0 +1,4 @@
|
|||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Video viewer
|
||||
Exec=/usr/bin/mpv -quiet %f
|
Loading…
Reference in New Issue