From fb2af0a5baf20abe7a9786b088ea28869c53f9ea Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Mon, 29 Apr 2019 07:48:07 +0100 Subject: [PATCH] Adds rofi-print --- bin/rofi-print | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bin/rofi-print diff --git a/bin/rofi-print b/bin/rofi-print new file mode 100755 index 00000000..5478ce31 --- /dev/null +++ b/bin/rofi-print @@ -0,0 +1,42 @@ +#!/bin/bash +# printpdf - script +# usage: +# printpdf file.pdf +# printpdf file1.pdf file2.pdf +# printpdf *.pdf +# by i_magnific0 +# Modified by jab2870 + +#COLORS=" -nb #303030 -nf khaki -sb #CCFFAA -sf #303030" +#if dmenu --help 2>&1 | grep -q '\[-rs\] \[-ni\] \[-nl\] \[-xs\]' +#then +# DMENU="dmenu -i -xs -rs -l 10" # vertical patch +#else +# DMENU="dmenu -i" # horizontal, oh well! +#fi + +DMENU="rofi -dmenu" + +printer=$( lpstat -p | awk '{print $2}' | $DMENU -p 'Printer:' $COLORS | perl -p -e 's/^.*?: ?//' ) + +set_options=$( echo -e 'No\nYes' | $DMENU -p 'Set options?' $COLORS | perl -p -e 's/^.*?: ?//' ) + +options="" + +# standard options to lpr, not in the printer lpstat -l +standard_options="page-ranges\nlandscape" + +while [ $set_options == "Yes" ]; do + custom_options=$( lpoptions -d $printer -l | grep -v NotInstalled | awk '{ print $1 }' | sed 's/:\+//g' ) + option_to_set=$( echo -e "$standard_options\n$custom_options" | $DMENU -p 'Option:' $COLORS | perl -p -e 's/^.*?: ?//' ) + option_value=$( lpoptions -d $printer -l | grep $option_to_set | awk 'BEGIN { FS = ": " } ; { print $2 }' | sed 's/ \+/\n/g' | sed 's/*\+//g' | $DMENU -p 'Setting:' $COLORS | perl -p -e 's/^.*?: ?//' ) + option_to_set_1d=$( echo $option_to_set | awk 'BEGIN { FS = "/" } ; { print $1 }' ) + if [ -z $option_value ]; then + options=$options"-o $option_to_set_1d " + else + options=$options"-o $option_to_set_1d=$option_value " + fi + set_options=$( echo -e 'No\nYes' | $DMENU -p 'Set more options?' $COLORS | perl -p -e 's/^.*?: ?//' ) +done + +lpr $options -P $printer $@