aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-09-12 23:48:55 +0530
committerAkshay Nair <phenax5@gmail.com>2024-09-12 23:48:55 +0530
commitce028570c53c8c45661d9fe0168920db05737c39 (patch)
tree544ea75ff17d66adbd4cce38fb312b2989e4dea6 /modules
parentc246b02edafe0d5ee2b690c0c1f899e917c88068 (diff)
downloadnixos-config-ce028570c53c8c45661d9fe0168920db05737c39.tar.gz
nixos-config-ce028570c53c8c45661d9fe0168920db05737c39.zip
Add tts and torrent integration to newsboat
Diffstat (limited to 'modules')
-rw-r--r--modules/newsboat.home/.gitignore2
-rw-r--r--modules/newsboat.home/config.nix23
-rw-r--r--modules/newsboat.home/default.nix10
-rwxr-xr-xmodules/newsboat.home/opener.sh39
-rw-r--r--modules/newsboat.home/public-feed.nix57
5 files changed, 93 insertions, 38 deletions
diff --git a/modules/newsboat.home/.gitignore b/modules/newsboat.home/.gitignore
index 16189dc..fd74620 100644
--- a/modules/newsboat.home/.gitignore
+++ b/modules/newsboat.home/.gitignore
@@ -1 +1 @@
-./private-feed.nix
+private-feed.nix
diff --git a/modules/newsboat.home/config.nix b/modules/newsboat.home/config.nix
index 2669482..e2e4514 100644
--- a/modules/newsboat.home/config.nix
+++ b/modules/newsboat.home/config.nix
@@ -1,8 +1,13 @@
-rec {
+let
+ opener = c: "~/.config/newsboat/opener.sh ${c}";
+ openCmd = opener "'%t' %u";
+ openLinkWith = c: ''set browser "${c}"; open-in-browser; set browser "${openCmd}"'';
+ pipeTo = c: "pipe-to \"${c}\"";
+in {
config = {
reload-threads = 6;
- max-items = 20;
- browser = "~/.config/newsboat/opener.sh '%t' %u";
+ # max-items = 20;
+ browser = openCmd;
show-keymap-hint = false;
refresh-on-startup = true;
save-path = "~/Downloads/articles";
@@ -18,14 +23,14 @@ rec {
g = "home";
G = "end";
q = "hard-quit";
- n = "next";
- p = "prev";
+ n = "next-unread";
+ p = "prev-unread";
};
- macros = let
- copyCmd = "~/.config/newsboat/opener.sh copy %u";
- in {
- y = ''set browser "${copyCmd}"; open-in-browser; set browser "${config.browser}"'';
+ macros = {
+ y = openLinkWith (opener "copy %u");
+ t = pipeTo (opener "tts");
+ s = openLinkWith (opener "torrent-stream '%u'");
};
extraConfig = ''
diff --git a/modules/newsboat.home/default.nix b/modules/newsboat.home/default.nix
index aedf7db..9e088c8 100644
--- a/modules/newsboat.home/default.nix
+++ b/modules/newsboat.home/default.nix
@@ -9,7 +9,7 @@ let
if lib.isList value
then value ++ (if acc != null then acc else [])
else value // (if acc != null then acc else {})
- ) null ([{ queries = {}; visible = []; hidden = []; }] ++ feeds);
+ ) null ([{ queries = []; visible = []; hidden = []; }] ++ feeds);
joinLines = lib.concatStringsSep "\n";
joinWords = lib.concatStringsSep " ";
@@ -24,7 +24,7 @@ let
toUrls = urls: joinLines (lib.map toUrl urls);
toQueries = queries: joinLines
- (lib.mapAttrsToList (key: val: "\"query:${key}:${val}\"") queries);
+ (lib.map (q: "\"query:${q.title}:${q.query}\"") queries);
# { raw = a; } -> a | bool -> yesno | string -> "string" | number
toConfigValue = val:
@@ -49,7 +49,11 @@ let
(toUrls (lib.map (x: x // { hidden = true; }) urls.hidden))
];
in {
- home.packages = [ pkgs.newsboat ];
+ home.packages = [
+ pkgs.newsboat
+ pkgs.piper-tts
+ pkgs.nodePackages.peerflix
+ ];
xdg.configFile = {
"newsboat/urls".text = urlsFileContent;
diff --git a/modules/newsboat.home/opener.sh b/modules/newsboat.home/opener.sh
index 7a5da4e..5d0cbfc 100755
--- a/modules/newsboat.home/opener.sh
+++ b/modules/newsboat.home/opener.sh
@@ -2,25 +2,54 @@
type="$1"; shift;
+spawn() { setsid -f "$@" >/dev/null 2>&1; }
+
video() {
- mpv \
+ spawn mpv \
+ -keep-open \
--player-operation-mode=pseudo-gui \
--force-window=immediate \
- "$@" >/dev/null 2>&1 & disown;
+ "$@";
+}
+
+image() { spawn feh -x -F --image-bg "#0f0c19" "$@"; }
+
+__tts() {
+ # local tts_model="en_US-ryan-high.onnx";
+ local tts_model="en_US-lessac-medium.onnx";
+ local tts_model_path="$HOME/.config/piper-models/$tts_model";
+ [ -f "$tts_model_path" ] || (echo "Model not found" && exit 1);
+
+ local tmp_file=$(mktemp /tmp/newsboat-piper-tts.XXX);
+ notify-send -t 6000 'Loading tts...';
+ piper --model "$tts_model_path" -f "$tmp_file" --sentence_silence 0.4;
+ video "$tmp_file";
}
-image() { feh -x -F --image-bg "#0f0c19" "$@" >/dev/null 2>&1 & disown; }
+tts() { __tts >/dev/null 2>&1; }
+
+browser() { spawn sensible-browser "$@"; }
-browser() { sensible-browser "$@" >/dev/null 2>&1 & disown; }
+torrent-dl() { ~/scripts/torrent.sh torrent "$1" >/dev/null 2>&1; }
+
+torrent-stream() {
+ notify-send -t 10000 'Starting stream player...';
+ spawn peerflix "$1" --mpv -- -keep-open --force-window=immediate >/dev/null 2>&1;
+}
case "$type" in
copy) echo "$@" | xclip -selection clipboard ;;
+ tts) tts ;;
image) image "$@" ;;
video|audio) video "$@" ;;
+ torrent-dl) torrent-dl "$@" ;;
+ torrent-stream) torrent-stream "$@" ;;
*)
case "$1" in
https://*youtu.be/*|https://*youtube.com/v/*) video "$@" ;;
https://*youtube.com/watch*) video "$@" ;;
- *) browser ;;
+ magnet:*) torrent-dl "$@" ;;
+ https*.torrent) torrent-dl "$@" ;;
+ *) browser "$@" ;;
esac
;;
esac;
diff --git a/modules/newsboat.home/public-feed.nix b/modules/newsboat.home/public-feed.nix
index 09ea6a7..b48284c 100644
--- a/modules/newsboat.home/public-feed.nix
+++ b/modules/newsboat.home/public-feed.nix
@@ -1,16 +1,22 @@
let
tag = t: ''tags # \"${toString t}\"'';
- youtube = title: id: tags:
- { title = "[yt] ${title} youtube"; url = "https://www.youtube.com/feeds/videos.xml?channel_id=${id}"; tags = ["youtube"] ++ tags; };
-in {
- queries = {
- "dev tag" = tag "dev";
- "news tag" = tag "news";
- "opensource tag" = tag "opensource";
- "youtube tag" = tag "youtube";
- "funny tag" = tag "funny";
- "science tag" = tag "sci";
+ youtube = title: id: tags: {
+ title = "[yt] ${title} youtube";
+ url = "https://www.youtube.com/feeds/videos.xml?channel_id=${id}";
+ tags = ["youtube"] ++ tags;
};
+in {
+ queries = [
+ { title = "#dev-blog"; query = tag "dev-blog"; }
+ { title = "#dev"; query = tag "dev"; }
+ { title = "#podcast"; query = tag "podcast"; }
+ { title = "#opensource"; query = tag "opensource"; }
+ { title = "#funny"; query = tag "funny"; }
+ { title = "#youtube"; query = tag "youtube"; }
+ { title = "#news"; query = tag "news"; }
+ { title = "#sci"; query = tag "sci"; }
+ { title = "#tv-shows"; query = tag "tv-shows"; }
+ ];
visible = [
{ url = "https://mshibanami.github.io/GitHubTrendingRSS/weekly/all.xml"; tags = ["latest"]; }
@@ -23,29 +29,37 @@ in {
{ url = "https://www.nasa.gov/news-release/feed/"; tags = ["sci"]; }
{ url = "https://www.nature.com/nature.rss"; tags = ["sci"]; }
{ url = "https://what-if.xkcd.com/feed.atom"; tags = ["sci"]; }
- { url = "https://overreacted.io/rss.xml"; tags = ["dev"]; }
- { url = "https://overreacted.io/rss.xml"; tags = ["dev"]; }
- { url = "https://kentcdodds.com/blog/rss.xml"; tags = ["dev"]; }
- { url = "https://developer.chrome.com/blog/feed.xml"; tags = ["dev"]; }
- { url = "https://programmingisterrible.com/rss"; tags = ["dev"]; }
+ { url = "https://feeds.transistor.fm/tomorrow"; tags = ["podcast"]; }
+ { url = "https://feed.syntax.fm/"; tags = ["podcast"]; }
+
+ { url = "https://overreacted.io/rss.xml"; tags = ["dev-blog"]; }
+ { url = "https://tkdodo.eu/blog/rss.xml"; tags = ["dev-blog"]; }
+ { url = "https://kentcdodds.com/blog/rss.xml"; tags = ["dev-blog"]; }
+ { url = "https://world.hey.com/dhh/feed.atom"; tags = ["dev-blog"]; }
+ { url = "https://developer.chrome.com/blog/feed.xml"; tags = ["dev-blog"]; }
+ { url = "https://programmingisterrible.com/rss"; tags = ["dev-blog"]; }
+ { url = "https://vercel.com/atom"; tags = ["dev-blog"]; }
+ { url = "https://reacttraining.com/rss.xml"; tags = ["dev-blog"]; }
+ { url = "https://www.developerway.com/rss.xml"; tags = ["dev-blog"]; }
+
{ url = "https://cprss.s3.amazonaws.com/javascriptweekly.com.xml"; tags = ["dev"]; }
{ url = "https://cprss.s3.amazonaws.com/react.statuscode.com.xml"; tags = ["dev"]; }
- { url = "https://dev.to/feed/tag/typescript"; tags = ["dev"]; title = "TS - dev.to"; }
+ { url = "https://www.totaltypescript.com/rss.xml"; tags = ["dev"]; }
{ url = "https://dev.to/feed/tag/haskell"; tags = ["dev"]; title = "Haskell - dev.to"; }
- { url = "https://nitter.privacydev.net/vim_tricks/rss"; tags = ["twitter" "dev" "opensource"]; }
+ { url = "https://devblogs.microsoft.com/typescript/feed/"; tags = ["news"]; }
+ { url = "https://dev.to/feed/tag/typescript"; tags = ["news"]; title = "TS - dev.to"; }
{ url = "https://hnrss.org/frontpage"; tags = ["news"]; }
{ url = "https://hackernoon.com/feed"; tags = ["news"]; }
+ { url = "https://nitter.privacydev.net/vim_tricks/rss"; tags = ["twitter" "opensource"]; }
{ url = "https://nixos.org/blog/announcements-rss.xml"; tags = ["opensource" "news"]; }
- { url = "https://www.reddit.com/r/opensource.rss"; tags = ["reddit" "opensource"]; title = "r/opensource"; }
{ url = "https://www.cyberciti.com/feed/"; tags = ["opensource" "news"]; }
{ url = "https://itsfoss.com/rss/"; tags = ["opensource" "news"]; }
+ { url = "https://www.reddit.com/r/opensource.rss"; tags = ["reddit" "opensource"]; title = "r/opensource"; }
{ url = "https://xkcd.com/rss.xml"; tags = ["funny"]; }
{ url = "http://phdcomics.com/gradfeed.php"; tags = ["funny"]; }
- { url = "https://www.reddit.com/r/ProgrammerHumor.rss"; tags = ["funny" "reddit"]; title = "r/ProgrammerHumor"; }
- { url = "https://feeds.feedburner.com/TheDailyWtf"; tags = ["funny"]; }
# Youtube channels
(youtube "IamMoBo" "UCJswRv22oiUgmT1FuFeUekw" ["funny"])
@@ -55,5 +69,8 @@ in {
(youtube "Fireship" "UCsBjURrPoezykLs9EqgamOA" ["dev"])
(youtube "No boilerplate" "UCUMwY9iS8oMyWDYIe6_RmoA" ["dev"])
(youtube "TypeCraft" "UCo71RUe6DX4w-Vd47rFLXPg" ["dev"])
+ (youtube "exurb1a" "UCimiUgDLbi6P17BdaCZpVbg" [])
+ (youtube "Casually Explained" "UCr3cBLTYmIK9kY0F_OdFWFQ" ["funny"])
+ (youtube "zefrank1" "UCVpankR4HtoAVtYnFDUieYA" ["funny"])
];
}