From 13eb300e23f87b45d188665f577c7a38808a18fa Mon Sep 17 00:00:00 2001
From: Rudis Muiznieks
Date: Thu, 14 Apr 2022 08:34:08 -0500
Subject: [PATCH] new scripts from desktop
---
bin/batman | 2 +
qutebrowser/autoconfig.yml | 1 +
qutebrowser/userscripts/view_in_mpv | 143 ++++++++++++++++++++++++++++
shell/bashrc.d/01-common.sh | 1 +
shell/bashrc.d/02-plugin-config.sh | 2 +-
5 files changed, 148 insertions(+), 1 deletion(-)
create mode 100755 bin/batman
create mode 100755 qutebrowser/userscripts/view_in_mpv
diff --git a/bin/batman b/bin/batman
new file mode 100755
index 0000000..4244604
--- /dev/null
+++ b/bin/batman
@@ -0,0 +1,2 @@
+#!/bin/sh
+col -bx < "$1" | bat --language man -p
diff --git a/qutebrowser/autoconfig.yml b/qutebrowser/autoconfig.yml
index 319076e..c24d89e 100644
--- a/qutebrowser/autoconfig.yml
+++ b/qutebrowser/autoconfig.yml
@@ -10,6 +10,7 @@ settings:
global:
normal:
',p': spawn --userscript qutepocket
+ ',m': spawn --userscript view_in_mpv
content.canvas_reading:
global: false
content.geolocation:
diff --git a/qutebrowser/userscripts/view_in_mpv b/qutebrowser/userscripts/view_in_mpv
new file mode 100755
index 0000000..4729204
--- /dev/null
+++ b/qutebrowser/userscripts/view_in_mpv
@@ -0,0 +1,143 @@
+#!/usr/bin/env bash
+#
+# Behavior:
+# Userscript for qutebrowser which views the current web page in mpv using
+# sensible mpv-flags. While viewing the page in MPV, all
+
+ In order to restore this particular video
+ click here.
+
+ ";
+ replacement.style.position = "relative";
+ replacement.style.zIndex = "100003000000";
+ replacement.style.fontSize = "1rem";
+ replacement.style.textAlign = "center";
+ replacement.style.verticalAlign = "middle";
+ replacement.style.height = "100%";
+ replacement.style.background = "#101010";
+ replacement.style.color = "white";
+ replacement.style.border = "4px dashed #545454";
+ replacement.style.padding = "2em";
+ replacement.style.margin = "auto";
+ App.all_replacements[i] = replacement;
+ App.backup_videos[i] = video;
+ video.parentNode.replaceChild(replacement, video);
+ }
+
+ function restore_video(obj, index) {
+ obj = App.all_replacements[index];
+ video = App.backup_videos[index];
+ console.log(video);
+ obj.parentNode.replaceChild(video, obj);
+ }
+
+ /** force repainting the video, thanks to:
+ * http://web.archive.org/web/20151029064649/https://martinwolf.org/2014/06/10/force-repaint-of-an-element-with-javascript/
+ */
+ var siteHeader = document.getElementById('header');
+ siteHeader.style.display='none';
+ siteHeader.offsetHeight; // no need to store this anywhere, the reference is enough
+ siteHeader.style.display='block';
+
+EOF
+}
+
+printjs() {
+ js | sed 's,//.*$,,' | tr '\n' ' '
+}
+echo "jseval -q $(printjs)" >> "$QUTE_FIFO"
+
+msg info "Opening $QUTE_URL with mpv"
+"${video_command[@]}" "$@" "$QUTE_URL"
diff --git a/shell/bashrc.d/01-common.sh b/shell/bashrc.d/01-common.sh
index e24409d..e3ca2b0 100644
--- a/shell/bashrc.d/01-common.sh
+++ b/shell/bashrc.d/01-common.sh
@@ -15,6 +15,7 @@ export PATH=$PATH:~/skynet/bin:~/node/node_modules/.bin:~/.local/bin:~/go/bin:~/
export EDITOR=vim
export PAGER=bat
+export MANPAGER=batman
export BROWSER=qutebrowser
export BAT_THEME='Wombat'
export DOTNET_ROOT=~/.dotnet
diff --git a/shell/bashrc.d/02-plugin-config.sh b/shell/bashrc.d/02-plugin-config.sh
index 82b69c4..e59c729 100644
--- a/shell/bashrc.d/02-plugin-config.sh
+++ b/shell/bashrc.d/02-plugin-config.sh
@@ -10,7 +10,7 @@ test -e /usr/share/bash-completion/bash_completion && source /usr/share/bash-com
# colorizer
GRC_ALIASES=true
-test -e /etc/profile.d/grc.sh && source /etc/profile.d/grc.sh
+test -e /usr/share/grc/grc.sh && source /usr/share/grc/grc.sh
# git bash completions
test -e ~/skynet/scripts/git-completion.bash && source ~/skynet/scripts/git-completion.bash