scripts

Various scripts for UNIX-like systems
git clone https://git.tronto.net/scripts
Download | Log | Files | Refs | README

commit b227267cea3afa3a7e39bb24c20d500262f32c12
parent feeb30effb2f41b3fdc2f76c9e45869c9e601ed4
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Wed, 24 Nov 2021 00:34:10 +0100

Some changes for new temrinal file management style

Diffstat:
Mopen-file | 34++++++++++++++++++++++++----------
Mopen-stdin | 4++--
Mxplumb | 2+-
3 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/open-file b/open-file @@ -10,6 +10,15 @@ menu=${MENU:-dmenu} +video=${VIDEOPLAYER:-mpv} +music=${MUSICPLAYER:-mpv} +pdf=${VIEWER:-zathura} +img=${IMAGEVIEWER:-imv} +word=${TEXTDOCUMENT:-libreoffice} +sheet=${SPREADSHEET:-libreoffice} +html=${HTMLVIEWER:-firefox} +xedit=${XEDITOR:-gedit} + while getopts "s:t:" opt; do case "$opt" in s) @@ -23,39 +32,44 @@ done shift `expr $OPTIND - 1` -[ -z "$launcher" ] && launcher="spawn" +# If launcher = "", assume running in terminal, so some programs change +if [ -z "$launcher" ]; then + xedit=${EDITOR:-vi} +fi + +#[ -z "$launcher" ] && launcher="spawn" [ -z "$mimetype" ] && mimetype="$(file --mime-type "$1" -bL)" -[ -d "$1" ] && $launcher $XFILEMANAGER "$1" && exit 0 +[ -d "$1" ] && echo "$1: is a directory" && exit 1 [ ! -f "$1" ] && echo "$1: bad argument" && exit 1 case "$mimetype" in video/*) - $launcher $VIDEOPLAYER "$1" + $launcher $video "$1" ;; audio/*) - $launcher $MUSICPLAYER "$1" + $launcher $music "$1" ;; application/pdf | application/postscript | image/vnd.djvu) - $launcher $VIEWER "$1" + $launcher $pdf "$1" ;; image/*) - $launcher $IMAGEVIEWER "$1" + $launcher $img "$1" ;; application/msword | \ application/vnd.oasis.opendocument.text | text/rtf | \ application/vnd.openxmlformats-officedocument.wordprocessingml.*) - $launcher $TEXTDOCUMENT "$1" + $launcher $word "$1" ;; application/ms-excel | application/vnd.oasis.opendocument.spreadsheet | \ text/rtf | application/vnd.openxmlformats-officedocument.spreadsheetml.*) - $launcher $SPREADSHEET "$1" + $launcher $sheet "$1" ;; text/html | text/enriched) - $launcher $HTMLVIEWER "$1" + $launcher $html "$1" ;; text/*) - $launcher $XEDITOR "$1" + $launcher $xedit "$1" ;; application/zip) unzip "$1" diff --git a/open-stdin b/open-stdin @@ -1,6 +1,6 @@ #!/bin/sh -# Saves standard input in a download folder and opens it with myopen +# Saves standard input in a download folder and opens it (spawn) # Usage: open-stdin # Requires: open-file @@ -9,4 +9,4 @@ folder=${TMPDIR:-/tmp} tempfile=$(mktemp -p "$folder") -cat > "$tempfile" && open-file -t "$1" "$tempfile" +cat > "$tempfile" && open-file -s spawn -t "$1" "$tempfile" diff --git a/xplumb b/xplumb @@ -59,7 +59,7 @@ tryurl() { ( [ -n "$url" ] && $browser $url ) || return 1 } -open-file "$text" || \ +open-file -s spawn "$text" || \ tryurl "$text" || \ trymail "$text" || \ tryman "$text" || \