3

I have seen years ago a very handy application: the command displayed it's first argument enlarged to fit the whole screen. For example...

thiscommand AA

...then you could see two very big A letters filling the whole screen, or...

thiscommand "name@mail.com"

...then the email address was shown that it's width was equal to the width of the screen. With a single keystroke (probably q) you could close it. I think this app is often very useful, when you talk with people or have a presentation, and you quickly need to show some short text, only few words.

My problem is that I forgot the name of this program, and I tried very hard to find by google, without success. Anybody knows it?

  • If you are still interested in this let me know and I'll post my script here. – PM 2Ring Nov 7 '14 at 1:55
  • yes, it would be great! – deeenes Mar 18 '15 at 21:03
4

banner; on my system it's called printerbanner. I was going to link to a man page, but I can't find one, either online or on my HD...

printerbanner prints the text sideways, to allow for very long strings, it doesn't seem to have an option to print normally.

Examples (courtesy of slm)

$ banner ken

      #    #  #######  #     #
      #   #   #        ##    #
      #  #    #        # #   #
      ###     #####    #  #  #
      #  #    #        #   # #
      #   #   #        #    ##
      #    #  #######  #     #

Multiple arguments are printed on separate lines:

$ banner one two

      #######  #     #  #######
      #     #  ##    #  #
      #     #  # #   #  #
      #     #  #  #  #  #####
      #     #  #   # #  #
      #     #  #    ##  #
      #######  #     #  #######

      #######  #     #  #######
         #     #  #  #  #     #
         #     #  #  #  #     #
         #     #  #  #  #     #
         #     #  #  #  #     #
         #     #  #  #  #     #
         #      ## ##   #######

Thanks for those examples, slm. My printerbanner prints sideways, like this:

printerbanner -w 64 ken

           ##                                        ## 
           ############################################ 
           ############################################ 
           ############################################ 
           ############################################ 
           ##           #### 
                      ########
                    ########### 
                  ##########  ###
           ##  ###########     ### ## 
           #############         #### 
           ##########             ### 
           ########                ## 
           ######
           ### 
           ##
                    ######## 
                ################
              ####################
             ###################### 
            ####       ##       #### 
            ##         ##         ###
           ##          ##          ## 
           ##          ##          ## 
           ##          ##          ## 
            #          ##         ###
            #          ##        ### 
            ##         ##    #######
             ###       ############
               ##      ##########
                       ########

           ##                      ## 
           ########################## 
           ########################## 
           ########################## 
           ########################## 
           ##                  ###
                                 ## 
                                 ### 
                                  ###
                                  ### 
           ##                    #### 
           ########################## 
           ##########################
           #########################
           ###################### 
           ##

Here's an example of the PostScript program produced by the current version of the Bash script I mentioned in the comments. Sorry about the lack of syntax highlighting, but the highlighting done for lang-ps or lang-postscript is horrible.

demo.ps

%!PS-Adobe-3.0
%%BoundingBox: 0 0 1024 768
%%Title: (TextLine)
%%Pages: 1 1
%%Creator: PSTextLine by PM 2Ring
%%Creationdate: 2014.11.07 13:30:51
%%EndComments

16 dict begin

%Use ISO Latin 1 font encoding
/ISOLatin{
    dup length dict begin
    {1 index /FID ne {def}{pop pop}ifelse}forall
    /Encoding ISOLatin1Encoding def
    currentdict
    end
   /IsoL1 exch definefont 
}bind def

%Show string centred on the page and scaled to fill the page
/ShowCentred{
    0 0 moveto

    %Get string's bounding box.
    dup
    false charpath
    flattenpath pathbbox
    newpath

    %Stack - Left Bottom Right Top
    /y1 exch def /x1 exch def
    /y0 exch def /x0 exch def

    %Calculate new font scale
    currentfont
    /sx XM Margin sub  x1 x0 sub  div def
    /sy YM Margin sub  y1 y0 sub  div def
    /Scale sx sy le {sx}{sy}ifelse def
    Scale scalefont setfont

    %Calculate coordinates that will shift the centre of the box to the page centre
    XM  x0 x1 add Scale mul sub 2 div
    YM  y0 y1 add Scale mul sub 2 div
    moveto
    show
}bind def

%%Page: 1 1
gsave

/XM 1024 def
/YM 768 def

%Twice the X & Y margins
/Margin 16 def

/Times-Roman findfont 
ISOLatin
72 scalefont setfont

(Unix & Linux)
ShowCentred

grestore

showpage
end
%%PageTrailer
%%Trailer
%%EOF

It should display properly with any PostScript viewer, eg okular. To show it with the ImageMagick / GraphicsMagick display utility:

display -geometry 1024x768 -density 72 demo.ps

Increase the density parameter (eg, try 300) to improve the quality of the rendered image. You can show the image in a backdrop window using display's -backdrop option; use Control-Q to close the window.

You can modify the text string (Unix & Linux) in demo.ps; the program will automatically compute the correct font size to use.

To convert demo.ps to PDF you could use the ImageMagick / GraphicsMagick convert utility

convert -page 1024x768 demo.ps demo.pdf

But it's probably faster (and with more compact output) to use

ps2pdfwr -g1024x768 -r72  demo.ps demo.pdf

At long last, here's the Bash script I was talking about earlier. Run it with no args, or an arg of -h for a help message; -hh prints extra help.

PSTextLine

#!/usr/bin/env bash

#Generate a Postscript file that prints a line of text that fills the screen

#Written by PM 2Ring 2014.11.01
#Posted to http://unix.stackexchange.com/a/164977/88378

bold(){ echo -e "\x1b[1m$*\x1b[0m"; }

help1()
{
    cat << EOF

Display a single line of text at the largest scale that fits within the screen (or requested size).

This script generates a Postscript program which performs the scaling calculation and sets the text
in the requested font. The Postscript file is then displayed using the ImageMagick / GraphicsMagick
utility $(bold display), which should be installed on most modern Linux systems.

$(bold Usage:)
$(basename "$0") [-h] [-bden] [-f fontname] [-g geometry] [-m margin] [-q quality] [-s savename.ps] [-t text] text...

Options may be given in any order.

$(bold Options:)
    -h : print this Help & exit. -hh prints extra help.
    -b : disable the use of a Backdrop window.
    -d : disable Display of the text.
    -e : disable backslash Escaping of the text string.
    -n : use Normal encoding instead of the default ISO Latin1 encoding.

    -f : the name of the Font, either a PostScript or system font. Default = 'Times-Roman'
    -g : Geometry, in WIDTHxHEIGHT format. If not given, the current default screen size is used.
    -m : left & right (&/or top & bottom) Margin (in pixels) around text bounding box. Default = 8
    -q : rendering Quality. Default quality = 1.0
    -s : Save PostScript. Use $(bold '-s -') to save to stdout.
    -t : the Text to display.
EOF
}

help2()
{
    cat << EOF

By default, $(bold display) shows the text in a backdrop window. You can use Control-Q to close
$(bold display) windows, or use a right mouse click to bring up a context menu.
See the $(bold display) documentation for further information.

$(bold Text)
Multiple -t text options may be given, they will be joined together with an intervening space.
Any arguments specified after the options will be added to the text, so there is no need to quote
the text string, but it will be necessary to use -- to terminate the options section if any of the
subsequent text words begin with a - dash.

$(bold Font)
The font name must conform to the PostScript naming convention,
in particular, it cannot contain spaces. So if a font you'd like to use does
have spaces in its name try dropping the spaces or replacing them with a - dash.

$(bold Quality)
The quality setting is essentially an internal scaling factor for the $(bold display) utility.
The default quality setting of 1.0 is reasonably fast, but the outline of the text may look
jagged, especially with short text strings. Lower quality settings may be a little faster,
but the outline can look quite blurry; settings lower than 0.2 are virtually unusable.
High quality settings take longer to render but can look quite good; 2.0 should be
adequate for most purposes, 4.0 takes quite a while to render but looks great; higher settings
take even longer but the improved quality is unlikely to be noticeable.

$(bold Save)
Normally, the PostScript program generated by this script is simply piped into the $(bold display)
utility, but you may save it to a file. This allows you to show (or print) the rendered text
with other PostScript utilities. If you wish, you can edit the PostScript program by hand,
to change the font, text, page size, etc, as the text scaling calculations are performed within the
PostScript program.

To display the file "savename.ps" with okular:
okular savename.ps

To display it with GhostScript in a 1024x768 window:
gs -sDEVICE=x11alpha -dBATCH -g1024x768 -r72 savename.ps

$(bold Escape)
By default, this program prefixes all backslashes $(bold '\\') and parentheses $(bold '()') in
the text string with a backslash to convert the string to PostScript form.
You can disable this behaviour using the $(bold '-e') option.

The PostScript language uses backslash as an escape character, and it uses parentheses instead
of quotes to enclose strings; any unmatched parentheses in a string must be backslash escaped
(but matched parentheses are ok). PostScript understands various other standard C escape sequences,
including character codes represented by backslashed octal sequences, but it does not understand
hexadecimal escape sequences.
Please see a PostScript reference for further information.

$(bold Encoding)
By default, this program uses the ISO Latin 1 encoding for text, but you can use PostScript's
Normal encoding vector by specifying the $(bold '-n') option. This program does not support
Unicode text.

EOF
}

Usage()
{
    help1
    [[ $showhelp -gt 1 ]] && help2
    exit "$1"
}

#Get args from command line
Getargs()
{
    showhelp=0
    backdrop="-backdrop"
    display=True
    escape=True
    encoding=ISOLatin
    font=Times-Roman
    geometry=""
    margin=8
    quality=1.0
    text=""
    savename=""

    while getopts ':hbdenf:g:m:q:t:s:' opt; do
        case $opt in
        h)
            showhelp=$((showhelp+1))
            ;;
        b)
            backdrop=""
            ;;
        d)
            display=False
            ;;
        e)
            escape=False
            ;;
        n)
            encoding=""
            ;;

        f)
            font=$OPTARG
            ;;
        g)
            geometry=$OPTARG
            ;;
        m)
            margin=$OPTARG
            ;;
        q)
            quality=$OPTARG
            ;;
        s)
            savename=$OPTARG
            ;;
        t)
            text="$text $OPTARG"
            ;;
        ?)
            bold "Bad option -$OPTARG"; Usage 1
            ;;
        esac
    done

    shift "$((OPTIND-1))" # Shift off the options and optional --.
    text="$text $*"
}

[[ $# = 0 ]] && Usage 0

Getargs "$@"

[[ $showhelp -gt 0 ]] && Usage 0

#Get current default screen dimensions if no geometry is specified
[[ -z $geometry ]] && geometry="$(xdpyinfo | awk '/dimensions:/{print $2}')"

#Trim leading & trailing spaces from the text.
read -rd '' text <<< "$text"

#Escape backslashes and parentheses
[[ $escape = True ]] && text="$(sed 's/[\()]/\\&/g' <<< "$text")"

#Allow '-' as a synonym for /dev/stdout for output file
[[ $savename = - ]] && savename=/dev/stdout

# cat << EOF
# $(bold Args)
# backdrop=<$backdrop>
# display=<$display>
# encoding=<$encoding>
# font=<$font>
# geometry=<$geometry>
# margin=<$margin>
# quality=<$quality>
# text=<$text>
# savename=<$savename>
#
# EOF

[[ -z $text ]] && { bold "No text found!"; Usage 1; }

[[ $display = False && -z $savename ]] &&
{ bold "No PostScript output or display requested!"; Usage 1; }

#Extract screen width & height from geometry string
IFS='x' read xm ym <<< "$geometry"

#Convert quality to density; the nominal density is 72 pixels per inch
density=$(bc <<< '72*'"$quality")

#Generate the PostScript file
read -rd '' postscript <<PSEOF
%!PS-Adobe-3.0
%%BoundingBox: 0 0 $xm $ym
%%Title: (TextLine)
%%Pages: 1 1
%%Creator: PSTextLine by PM 2Ring
%%Creationdate: $(date +'%Y.%m.%d %X')
%%EndComments

%%BeginProlog
16 dict begin

%Use ISO Latin 1 font encoding
/ISOLatin{
    dup length dict begin
    {1 index /FID ne {def}{pop pop}ifelse}forall
    /Encoding ISOLatin1Encoding def
    currentdict
    end
   /IsoL1 exch definefont
}bind def

%Show string centred on the page and scaled to fill the page
/ShowCentred{
    0 0 moveto

    %Get string's bounding box.
    dup
    false charpath
    flattenpath pathbbox
    newpath

    %Stack - Left Bottom Right Top
    /y1 exch def /x1 exch def
    /y0 exch def /x0 exch def

    %Calculate new font scale
    currentfont
    /sx XM Margin sub  x1 x0 sub  div def
    /sy YM Margin sub  y1 y0 sub  div def
    /Scale sx sy le {sx}{sy}ifelse def
    Scale scalefont setfont

    %Calculate coordinates that will shift the centre of the box to the page centre
    XM  x0 x1 add Scale mul sub 2 div
    YM  y0 y1 add Scale mul sub 2 div
    moveto
    show
}bind def
%%EndProlog
%%Page: 1 1
%%PageBoundingBox: 0 0 $xm $ym

gsave

/XM $xm def
/YM $ym def

%Twice the X & Y margins
/Margin $((2 * margin)) def

/$font findfont
$encoding
72 scalefont setfont

($text)
ShowCentred

grestore

showpage
end

%%PageTrailer
%%Trailer
%%EOF
PSEOF


[[ -n $savename ]] && echo >"$savename" "$postscript"

[[ $display = True ]] &&
display $backdrop -geometry "$geometry" -density "$density" PS:- <<< "$postscript"

# gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="$savename" -g"$geometry" -r72 - <<< "$postscript"
# display $backdrop -geometry "$geometry" -density "$density" "$savename"
  • Thanks this is great! However, what I am looking for, was an X11 application, creating a new window to display the text. – deeenes Oct 31 '14 at 19:57
  • 1
    @deeenes: I had a feeling that might be the case after I re-read the question. I couldn't think of such an application off-hand... so I wrote one. :) It's a bash script that writes a small PostScript program to render the text (using any PostScript or TTF font) and pipes that to display (part of the ImageMagick / GraphicsMagick package) to actually show the text in an X11 window. The bulk of the program is written, I mostly need to polish up the command line argument handling and the documentation. – PM 2Ring Nov 3 '14 at 23:10
  • I think that's wonderful that you take the effort to implement an easy and smart solution! it would be nice to post here (or link from pastebin/git or similar), i would be happy to see it, and and maybe others too. thanks for the nice answer! – deeenes Mar 18 '15 at 21:02
  • @deeenes: Thanks for reminding me about this project - I'd almost forgotten about it. And thanks for the points. :) I've added the bash script to the end of my answer. I didn't post it earlier because I didn't get any feedback from you after my last comment, so I figured you probably weren't interested in it... – PM 2Ring Mar 19 '15 at 10:07
5

I think you are searching for SM : screen message

Package: sm
Priority: optional
Section: universe/games
Installed-Size: 99
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Joachim Breitner <nomeata@debian.org>
Architecture: amd64
Source: screen-message
Version: 0.22.1-2
Depends: libc6 (>= 2.4), libcairo2 (>= 1.2.4), libglib2.0-0 (>= 2.14.0), libgtk-3-0 (>= 3.0.0), libpango-1.0-0 (>= 1.14.0), libpangocairo-1.0-0 (>= 1.14.0)
Filename: pool/universe/s/screen-message/sm_0.22.1-2_amd64.deb
Size: 14282
MD5sum: 9c3f592270a9a427d3b6685e2b17069d
SHA1: ee764a76a51717304c3adca698c28446e4d48205
SHA256: 73e896dd781d89638686d850f68aa452c6c2592993f181ef5b4db2787a3dac2a
Description-en: Displays a short text fullscreen
 Screen Message will display a given multi-line message as large as
 possible, fullscreen and black on white. You can specify the text either
 when launching sm, or edit it while the program is running.
 .
 It is useful to send messages across a room, e.g. during an university
 lecture. For fast startup, it is recommended to bind it to a key in your
 Desktop Environment.
Description-md5: 91fe8f689d157fbba591713d7e201f4d
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
  • big thanks! wonderful, i was looking exactly for this already for half year. :) – deeenes Mar 18 '15 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.