aboutsummaryrefslogtreecommitdiff
path: root/public/.local/bin/dmenu-openbook.sh
diff options
context:
space:
mode:
Diffstat (limited to 'public/.local/bin/dmenu-openbook.sh')
-rwxr-xr-xpublic/.local/bin/dmenu-openbook.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/public/.local/bin/dmenu-openbook.sh b/public/.local/bin/dmenu-openbook.sh
new file mode 100755
index 0000000..6a257c7
--- /dev/null
+++ b/public/.local/bin/dmenu-openbook.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# xdg-open a file selected through dmenu
+
+path="$HOME/docs/books"
+
+notify() {
+ mimetype=$(xdg-mime query filetype "$selected")
+ defaultprogram=$(xdg-mime query default "$mimetype")
+ notify-send "Opening $selected ($mimetype) with $defaultprogram"
+}
+
+cd $path
+files=$(find . -type f \( -iname "*.pdf" -o -iname "*.epub" \))
+selected=$(echo "$files" | dmenu -i -l 20 -p "Select book:")
+if [ -n "$selected" ]; then
+ xdg-open "$selected"
+ notify
+fi