6

Please suggest me a way to use any image like a re-sizable sticky note so that I can view it whenever I open my Unity Desktop.

I want it to be used like a homescreen photo widget app available on Android. So that even after rebooting my system, the image stays where it was positioned before, just like a sticky note.

What I want is depicted in the picture below:

enter image description here

In the above picture I placed the image on my Desktop, and resized the image icon to its maximum size, however this does not solve my problem as:

  • I cannot enlarge the image any further as this is the maximum size for resizing icons.

  • When I hover over the icon, the image gets highlighted which happens in case of icons, which I do not want

  • Even with the maximum icon size, the quality of the image becomes really poor as the image is distorted.

I want the image to be easily re-sized and re-positioned without having any of the disadvantages mentioned above.

I hope I am clear about my question now. If there is still any problem in understanding what I want please let me know.

(Ubuntu 16.04)

  • Which desktop are you using? Unity? GNOME? – Christophe Strobbe Oct 25 '17 at 14:11
  • 2
    What do you mean by "pin an image"? – user692175 Oct 25 '17 at 14:11
  • @MichaelBay I mean use the image as a sticky note, whenever I view my Desktop – Kewal Shah Oct 25 '17 at 14:15
  • 1
    @KewalShah I think you can simply place an image on desktop, right click on the icon, select resize icon, and increase its size. Is that not enough? – pomsky Oct 25 '17 at 14:55
  • 1
    @KewalShah Then try screenlets maybe. Not completely sure but I believe there's something for photos. – pomsky Oct 25 '17 at 15:51
6

Showing an image on your desktop

Windows can be of different types. We do not only have "normal" windows, but also windows of (in our case) type "DESKTOP".

Windows of type "DESKTOP" stay below everyting; even all items on your desktop show up above them. Therefore showing an image in a window then results into:

enter image description here

...where the sundew image, pinned on the desktop, is actually a window (just like the desktop clock in the image btw).

The code

#!/usr/bin/env python3
import gi
gi.require_version('GdkPixbuf', '2.0')
from gi.repository import GdkPixbuf
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk
import sys

img = sys.argv[1]
xpos = int(sys.argv[2])
ypos = int(sys.argv[3])
w = int(sys.argv[4])
h = int(sys.argv[5])

class ShowPortrait(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="PortraitonMyDesktop")
        self.set_type_hint(Gdk.WindowTypeHint.DESKTOP)
        self.connect("destroy", Gtk.main_quit)
        self.set_skip_taskbar_hint(True)
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
            img, w, h, preserve_aspect_ratio=True,
            )
        image = Gtk.Image.new_from_pixbuf(pixbuf)
        self.add(image)
        self.move(xpos, ypos)
        self.show_all()

ShowPortrait()
Gtk.main()

How to use

  1. Copy the script into an empty file, save it as showportrait.py
  2. Test- run it with the image, the x-position, y-position, width and height as arguments:

    python3 /path/to/showportrait.py /path/to/image x y width height
    

    for example:

    python3 '/home/jacob/Desktop/showportrait.py' '/home/jacob/Thema/Wallpapers/sundew.jpg' 1000 200 400 400
    

    The image should show on your desktop.

  3. If all works fine, add the command to Startup Applications.

Closing the window

Is easyest done by the command:

kill "$(pgrep -f showportrait.py)"

Note

Setting the width/hight, the script will scale the image until the first is reached, preserving the image' proportions.

  • Amazing, I just tried your script on UbuntuStudio and it worked so far. Small caveat: as soon as I left-click somewhere on the Desktop the image disappears, the script is still running though. But this is probably related to the different DE. No need to improve the script if works on plain Ubuntu, I was just curious if it would work on my system too, upvoted... Have a nice day! – mook765 Oct 28 '17 at 10:53
  • @mook765 ah, that is interesting, and probably easily fixable. Do you have wmctrl installed? If so, does the window still appear in wmctrl -l ? – Jacob Vlijm Oct 28 '17 at 10:58
  • @mook765 Added one line, does that make a difference? – Jacob Vlijm Oct 28 '17 at 11:05
  • 1
    @KewalShah, Thanks for trying a screenlet and describing how it works. Let us hope that Jacob will find it interesting and have time to do a GUI version of his python script showportrait.py – sudodus Oct 29 '17 at 18:15
  • 1
    Classic Jacob with Gtk.Window, +1 – Sergiy Kolodyazhnyy Oct 30 '17 at 5:11

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.