aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-24 00:34:10 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-24 00:34:10 +0100
commitb227267cea3afa3a7e39bb24c20d500262f32c12 (patch)
tree4a9f8b55d3bec0fba7a6da881c10416e2876450e
parentfeeb30effb2f41b3fdc2f76c9e45869c9e601ed4 (diff)
downloadscripts-b227267cea3afa3a7e39bb24c20d500262f32c12.tar.gz
scripts-b227267cea3afa3a7e39bb24c20d500262f32c12.zip
Some changes for new temrinal file management style
Diffstat (limited to '')
-rwxr-xr-xopen-file34
-rwxr-xr-xopen-stdin4
-rwxr-xr-xxplumb2
3 files changed, 27 insertions, 13 deletions
diff --git a/open-file b/open-file
index 0e8e210..9a54446 100755
--- a/open-file
+++ b/open-file
@@ -10,6 +10,15 @@
10 10
11menu=${MENU:-dmenu} 11menu=${MENU:-dmenu}
12 12
13video=${VIDEOPLAYER:-mpv}
14music=${MUSICPLAYER:-mpv}
15pdf=${VIEWER:-zathura}
16img=${IMAGEVIEWER:-imv}
17word=${TEXTDOCUMENT:-libreoffice}
18sheet=${SPREADSHEET:-libreoffice}
19html=${HTMLVIEWER:-firefox}
20xedit=${XEDITOR:-gedit}
21
13while getopts "s:t:" opt; do 22while getopts "s:t:" opt; do
14 case "$opt" in 23 case "$opt" in
15 s) 24 s)
@@ -23,39 +32,44 @@ done
23 32
24shift `expr $OPTIND - 1` 33shift `expr $OPTIND - 1`
25 34
26[ -z "$launcher" ] && launcher="spawn" 35# If launcher = "", assume running in terminal, so some programs change
36if [ -z "$launcher" ]; then
37 xedit=${EDITOR:-vi}
38fi
39
40#[ -z "$launcher" ] && launcher="spawn"
27[ -z "$mimetype" ] && mimetype="$(file --mime-type "$1" -bL)" 41[ -z "$mimetype" ] && mimetype="$(file --mime-type "$1" -bL)"
28 42
29[ -d "$1" ] && $launcher $XFILEMANAGER "$1" && exit 0 43[ -d "$1" ] && echo "$1: is a directory" && exit 1
30[ ! -f "$1" ] && echo "$1: bad argument" && exit 1 44[ ! -f "$1" ] && echo "$1: bad argument" && exit 1
31 45
32case "$mimetype" in 46case "$mimetype" in
33 video/*) 47 video/*)
34 $launcher $VIDEOPLAYER "$1" 48 $launcher $video "$1"
35 ;; 49 ;;
36 audio/*) 50 audio/*)
37 $launcher $MUSICPLAYER "$1" 51 $launcher $music "$1"
38 ;; 52 ;;
39 application/pdf | application/postscript | image/vnd.djvu) 53 application/pdf | application/postscript | image/vnd.djvu)
40 $launcher $VIEWER "$1" 54 $launcher $pdf "$1"
41 ;; 55 ;;
42 image/*) 56 image/*)
43 $launcher $IMAGEVIEWER "$1" 57 $launcher $img "$1"
44 ;; 58 ;;
45 application/msword | \ 59 application/msword | \
46 application/vnd.oasis.opendocument.text | text/rtf | \ 60 application/vnd.oasis.opendocument.text | text/rtf | \
47 application/vnd.openxmlformats-officedocument.wordprocessingml.*) 61 application/vnd.openxmlformats-officedocument.wordprocessingml.*)
48 $launcher $TEXTDOCUMENT "$1" 62 $launcher $word "$1"
49 ;; 63 ;;
50 application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \ 64 application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \
51 text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*) 65 text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*)
52 $launcher $SPREADSHEET "$1" 66 $launcher $sheet "$1"
53 ;; 67 ;;
54 text/html | text/enriched) 68 text/html | text/enriched)
55 $launcher $HTMLVIEWER "$1" 69 $launcher $html "$1"
56 ;; 70 ;;
57 text/*) 71 text/*)
58 $launcher $XEDITOR "$1" 72 $launcher $xedit "$1"
59 ;; 73 ;;
60 application/zip) 74 application/zip)
61 unzip "$1" 75 unzip "$1"
diff --git a/open-stdin b/open-stdin
index 48792b6..a776b9f 100755
--- a/open-stdin
+++ b/open-stdin
@@ -1,6 +1,6 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Saves standard input in a download folder and opens it with myopen 3# Saves standard input in a download folder and opens it (spawn)
4# Usage: open-stdin 4# Usage: open-stdin
5# Requires: open-file 5# Requires: open-file
6 6
@@ -9,4 +9,4 @@ folder=${TMPDIR:-/tmp}
9 9
10tempfile=$(mktemp -p "$folder") 10tempfile=$(mktemp -p "$folder")
11 11
12cat > "$tempfile" && open-file -t "$1" "$tempfile" 12cat > "$tempfile" && open-file -s spawn -t "$1" "$tempfile"
diff --git a/xplumb b/xplumb
index 977d2d5..c1ec6c9 100755
--- a/xplumb
+++ b/xplumb
@@ -59,7 +59,7 @@ tryurl() {
59 ( [ -n "$url" ] && $browser $url ) || return 1 59 ( [ -n "$url" ] && $browser $url ) || return 1
60} 60}
61 61
62open-file "$text" || \ 62open-file -s spawn "$text" || \
63tryurl "$text" || \ 63tryurl "$text" || \
64trymail "$text" || \ 64trymail "$text" || \
65tryman "$text" || \ 65tryman "$text" || \

Generated with cgit - Back to sebastiano.tronto.net