Show image notification from bash script - linux

What I'm trying to accomplish:
On Ubuntu 10.04 I'd like to display a small notification image in the corner of the screen and have the image fade out. I'd like to do it from the command line for use with bash scripts. Similar to "notify-send", "zenity", or "dialog" except
it displays images as well.
What I've found so far:
ImageMagick animate seems to be the only command line tool that can display an image and exit without user interaction.
Is there anything any better? I could write one myself but I thought there should already be something to do this.

gcin does the work. It shows full size images as notifications.
sudo apt-get install gcin
gcin-message -icon your_image.jpg
Extract of man gcin-message:
NAME
gcin-message - gcin's notification tool
SYNOPSIS
gcin-message [-icon file] [-text string] [-duration milliseconds]
DESCRIPTION
gcin-message displays notification image and/or text. It is useful for
filters to have interaction with users.
OPTIONS
-icon file
Display an image.
-text string
Display text string. The space character is not allowed.
-duration milliseconds
Time to show notifications.
However I suggest you to not use this tool, because its installation from the Ubuntu repository is not fine grained (6 MB of stuff and a chinese icon in the notification area).
See if you can get gcin-message out of the gcin package and put it into your own package (if this suits your needs).

Related

How are images shown in the terminal

Some packages like w3m-img, fim, lsix etc can be used to show the images directly on the terminal itself on linux.
I am not talking about converting the image into an ASCII character version and showing it but the image itself which looks proper without any the artifacts.
so how do these programs actually draw the images onto the terminal?
I've used Feh in the past. It should be already installed on popular Linux distributions. To use it, simply do the following:
feh your-image.jpeg

Linux Desktop app: How can I check a package icon?

Apparently, one can refer to a program's icon solely by its name, like here:
zenity --question --text "Hello <b>world</b>" --icon-name "baobab"
Try replacing baobab with gnome-terminal and the icon will change, you may even drop the quotes. Obviously there is some kind of abstraction at work here (I like those) with a database. (I know about .desktop files, and the xdg tools]1. But is there a CLI to display (of even more hefpul: don't display it if not found, throwing an error)) those icons in such a way, like eog baobab? (doesn't work.) I want to do that, display the icon of the program I' displaying, sometimes said programs come from larger packages, so I have no real way to know if it's installed.
How can I know that the icon has not been found (important)?
How can I get a list of all those "installed" icons?
How can I test like chk_icon "baobab" ; $?=0OK
How can I test like chk_icon "installed stuff" ; $?=0OK
Thanks!
I was able to add a new recognized icon name by copying my icons to the various /usr/share/icons/gnome directories, by size, and THEN running
sudo gtk-update-icon-cache /usr/share/icons/gnome
without which the icon will still not be recognized.

Render swf to png or other image format

How can I, on linux, render a swf to a image file?
I need to be able to load other swfs into that swf and run actionscript code.
Is it even possible on linux? I need to do it from PHP, it's fine if I have to use command-line tools.
swfrender from swftools works for basic SWF files.
swfdec-thumbnailer from swfdec-gnome works though it only gets the first frame of the swf.
To get any frame from swf using swfdec see the C code snippet in the following mailing list post.
gnash from gnash also works gnash -s<scale-image-factor> --screenshot last --screenshot-file output.png -1 -r1 input.swf, last image of the swf.
ffmpeg from ffmpeg also works for some swf formats ffmpeg -i movie.swf -f image2 -vcodec png movie%d.png
Also see the following guide for a commandline pipeline.
In order to call external programs from php you use the exec command documented here.
Note that for security reasons it is important to escape arguments passed to exec with another command like escapeshellcmd or escapeshellarg for security reasons.
Once you have converted to an image format whether for single frame or all frame, you can't run action script. Other non GNU / Linux tools support the export of the action script from from SWF.
If the SWF that you are exporting to PNG is too complicated for the other tools than you can use the Flash Plugin or Gnash and Xvfb along with screen capture software to capture either image frames of the SWF or a video format like avi. Then you can extract the images from the video format.
This virtual framebuffer method will support complicated SWF files, though it requires a lot of work as you need to use either Gnash and Xvfb and Screen Capture, or a browser , Xvfb and Selenium, if you want to capture a certain set of mouse / keyboard interactions with the SWF.
Gnash with and without the Virtual FrameBuffer should load the ActionScript before exporting, but may have issues with complicated ActionScript. Flash Plugin with Virtual Framebuffer will load the ActionScript before exporting.
Also see the following StackOverFlow questions, which you question is a duplicate of
Convert SWF to PNG
Render Flash (SWF) frame as image (PDF,PNG,JPG)
SWF to image (jpg, png, …) with PHP
This is the solution I ended up using.
You can use a tool like Xvfb (X11 server) and run the standalone flash player projector inside it (you may need to install a bunch of 32-bit libraries), then use a screen capture utility like import to capture the screen and crop it to size.
I found this page on rendering swf screenshots in linux helpful. It also says that you can use gnash to do this, however gnash won't work for flash player 9+.
Try this air application http://swfrenderer.kurst.co.uk
It render swf frame by frame

generate image (e.g. jpg) of a web page?

I want to create an image what a web page looks like,
e.g. create a small thumbnail of the html + images.
it does not have to be perfect (e.g. flash /javascript rendering).
I will call use the code on linux, ideally would be some java library, but a command line tool would be cool as well.
any ideas?
Try CutyCapt, a command-line utility. It uses Webkit for rendering and outputs in various formats (SVG, PNG, etc.).
you can get it nearly perfect, and cross platform too, by using a browser plugin.
FireShot or ScreenGrab for Firefox.
6 Google Chrome Screenshot Webpage Capture Extensions
BrowserShots is an open source project that may have some code you can use.
also see:
Command line program to create website screenshots (on Linux)
Convert web page to image
How to take screenshot of whole web page, rather than what shows on the screen
What is the best way to create a web page thumbnail?
Convert HTML to an image
To take a screenshot in the terminal with ImageMagick, type the following line into a terminal and then click-and-drag the mouse over a section of the screen:
import MyScreenshot.png
To capture the entire screen and after some delay and resize it, use the following command:
import -window root -resize 400×300 -delay 200 screenshot.png
You may use a mixture of xwininfo and import to retrieve the window id of the browser and make a screenshot of that window. A bash script to automate this process would be something like this:
#!/bin/bash
window_id=`xwininfo -tree -root | grep Mozilla | awk '{print $1}'`
import -window $window_id -resize 100x100 tumb.png
This script will create a 100x100 screenshot of Firefox on the current directory under the name tumb.png
Several sources show how to run a bash script from inside a Java application, google can help you on that. If you are in a hurry, check this and this.
After reading this page, I was thinking, let me fire up midori browser: http://midori-browser.org/ and when I tried the -h option, I have seen:
-s, --snapshot Take a snapshot of the specified URI
QutyCapt is difficult to compile, and has many dependencies. Midori has it less. It outputs the PNG of the website into TMP folder. One can get the file with:
midori -s http://www.rcdwealth.com new.png 2>/dev/null | awk '{ print $4}'
After that, the file can be converted to thumbnail size by using ImageMagick's convert program.
If you're interested in Java, maybe you could look at browser automation using Selenium-RC http://seleniumhq.com
It's a little java server that you can install on the box and the program itself will execute remote commands in a web browser.
Steps like (this is pseudo code by the way, I code my Selenium in php and I can't recall 100% of the specifics off the top of my head)
selenium.location("http://foo.com")
selenium.open("/folder/sub/bar.html")
selenium.captureScreenshot("/tmp/" + this.getClass().getName() + "."
+ testMethodName + ".png");
Actually, I just did a quick websearch for the exact syntax on that last one ... and this guy has a blog with what might actually be working code in java :)
https://dev.youdevise.com/YDBlog/index.php?title=capture_screenshots_of_selenium_browser_&more=1&c=1&tb=1&pb=1
There's also a number of websites that provide this service "cross browser and OS" I just can't recall what they are. Basically they've got a cloud of every single operating system and browser combination, and they log on with each machine, take a screen and store it on their site for you to come back to in a few hours when they're done.
Ahh... another websearch and it's yours :) http://browsershots.org/

Adding Security Message to RHEL 5 Login Screen

What are the steps to configure the login screen of Red Hat Enterprise Linux 5 to display a large paragraph of text?
Background Information: The text is a security warning required by the company I work for to be presented to all users prior to them logging in. They must be able to read the text prior to logging in.
We are using GDM and it does not read /etc/issue by default. I have placed a copy of the text under the [greeter] section in /etc/gdm/custom.conf. The issue is that the text is displayed on one line and runs off the screen.
Is there a way to present the whole paragraph in plain text without having to resort to using a rendered background image of the text such as how this DOE employee did?
Example of using image: http://cc.jlab.org/docs/security/banners/linux-graphical-banner.html
Place the text in a file, and point InfoMsgFile to the file.
[greater]
InfoMsgFile=/etc/motd

Resources