Coder Social home page Coder Social logo

xseticon's Introduction

Xterm, and likely many other X11 programs, do not set themselves window icons, which window managers typically use to represent that program window in switcher lists, taskbars, and so on. This program can set the X11 window icon for any given window, to that of a given image file.

Usage

usage: xseticon [options] path/to/icon.png
options:
  -name     : apply icon to the window of the name supplied
  -id   : apply icon to the window id supplied

Sets the window icon to the specified .png image. The image is loaded from
the file at runtime and sent to the X server; thereafter the file does not
need to exist, and can be deleted/renamed/modified without the X server or
window manager noticing.
If no window selection option is specified, the window can be interactively
selected using the cursor.

Hints:
  xseticon -id "$WINDOWID" path/to/icon.png
Will set the icon for an xterm.xseticon from Paul Evans (http://www.leonerd.org.uk/).

Build and install instructions

On Ubuntu / Debian:

# Install dependencies
sudo apt install libxmu-headers libgd-dev libxmu-dev libglib2.0-dev
# Build
make
# Install
sudo cp xseticon /usr/local/bin

On EL7:

# Install dependencies
sudo yum install libXmu-devel gd gd-devel glib2-devel
# Build
make
# Install
sudo cp xseticon /usr/local/bin

On openSUSE15:

# Install dependencies
sudo zypper in libXmu-devel glib2-devel gd-devel
# Build
make
# Install
sudo cp xseticon /usr/local/bin

Using Snap (requires snapd):

sudo snap install xseticon

Author

This is xseticon from Paul Evans (http://www.leonerd.org.uk/).

Note that there is another xseticon from Rustem Valeev on Sourceforge (https://sourceforge.net/projects/xseticon/).

License

See LICENSE file.

xseticon's People

Contributors

xeyownt avatar maeveynot avatar willwh avatar brlin-tw avatar

Stargazers

 avatar Supakorn Suttiruang avatar  avatar Ayamikhan avatar  avatar  avatar  avatar David Gao avatar Dan Wahl avatar Michael Benford avatar Mark Ulaya avatar Ryan Fortner avatar Jai A P avatar Richard avatar Alexander Mönnig avatar BLE TOU 202 FX National avatar Leandro Arruda avatar  avatar Kamen Mladenov avatar Dan Nelson avatar Benjamin Slade avatar Sören avatar DC-1 avatar  avatar Gokul Soumya avatar Anton Maminov avatar Robert Martin-Legene avatar Matt Stofko avatar  avatar Mitică avatar Alex avatar Serge K avatar John Skilleter avatar

Watchers

James Cloos avatar Michele Venturi avatar Rodolfo García Peñas (kix) avatar  avatar Alexander Mönnig avatar

xseticon's Issues

load_icon inside XSynchronize

Do I understand correctly that XSynchronize gives us an exclusive lock on screen interaction? From the man page, it looks like it should be released. Does XCloseDisplay do that? Then a comment near XCloseDisplay should clarify that.

In any case, if it's a lock, we shall try and hold it for the shortest duration possible. File access can be slow depending on circumstances and storage medium. We should thus load the image data earlier, ideally even before we interact with X at all, because failure to load the icon voids any usefulness of the X interaction. And since X interaction always carries risks of bad side effects¹, we should be very conservative about them.

(¹ I'm currently a victim of bad xdotool freezes that neither me nor IRC can trace even after many hours of debugging.)

Build error on Debian Sid

On debian sid, compilation exits with the error:

gcc -lglib-2.0 -L /usr/X11R6/lib -lX11 -lXmu -lgd xseticon.o -o xseticon
/usr/bin/ld: xseticon.o: in function `Window_With_Name':
xseticon.c:(.text+0x210): undefined reference to `XFetchName'
/usr/bin/ld: xseticon.c:(.text+0x25a): undefined reference to `XQueryTree'
/usr/bin/ld: xseticon.c:(.text+0x2c6): undefined reference to `XFree'
/usr/bin/ld: xseticon.o: in function `Select_Window_Mouse':
xseticon.c:(.text+0x5a3): undefined reference to `XCreateFontCursor'
/usr/bin/ld: xseticon.c:(.text+0x5dc): undefined reference to `XGrabPointer'
/usr/bin/ld: xseticon.c:(.text+0x619): undefined reference to `XAllowEvents'
/usr/bin/ld: xseticon.c:(.text+0x63b): undefined reference to `XWindowEvent'
/usr/bin/ld: xseticon.c:(.text+0x6a8): undefined reference to `XUngrabPointer'
/usr/bin/ld: xseticon.o: in function `load_icon':
xseticon.c:(.text+0x72d): undefined reference to `gdImageCreateFromPng'
/usr/bin/ld: xseticon.c:(.text+0x799): undefined reference to `g_malloc0_n'
/usr/bin/ld: xseticon.c:(.text+0x837): undefined reference to `gdImageGetPixel'
/usr/bin/ld: xseticon.c:(.text+0x961): undefined reference to `gdImageDestroy'
/usr/bin/ld: xseticon.o: in function `main':
xseticon.c:(.text+0xa22): undefined reference to `XOpenDisplay'
/usr/bin/ld: xseticon.c:(.text+0xa4a): undefined reference to `XSynchronize'
/usr/bin/ld: xseticon.c:(.text+0xae2): undefined reference to `XGetGeometry'
/usr/bin/ld: xseticon.c:(.text+0xb07): undefined reference to `XmuClientWindow'
/usr/bin/ld: xseticon.c:(.text+0xb45): undefined reference to `XInternAtom'
/usr/bin/ld: xseticon.c:(.text+0xbb4): undefined reference to `XChangeProperty'
/usr/bin/ld: xseticon.c:(.text+0xbd9): undefined reference to `XFlush'
/usr/bin/ld: xseticon.c:(.text+0xbfa): undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status
make: *** [Makefile:21: xseticon] Error 1

SVG support

Hi,

does this support svg image files? I tried and got a segmentation fault error, so I don't know if it's because I used a svg file or something else.

Thank you :)

Re building on openSUSE

This is not an issue.

I cannot find another way to message you.

To build on openSUSE Leap 15.5,
I needed to install gd-devel,

sudo zypper in gd-devel

Other dependencies were already present.

Your hint command line works fine
for XTerm, in WSL, on Windows 10.

Thank you,

Aya.

On Debian Buster, the package libglib2.0-dev is required

On Debian Buster (current testing distro), I got the error:

~/tools/xseticon$ make
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found

Installing libglib2.0-dev (sudo apt install libglib2.0-dev) fixed it. Thought you should add that dependency to the README.

Thanks for this handy piece of code!

Clarify license, potentially replace Fatal_Error

Between the lines // FROM programs/xlsfonts/dsimple.c and // END FROM, we currently have the functions

  • Fatal_Error
  • Window_With_Name
  • Select_Window_Args
  • Select_Window_Mouse

However, I can only find Fatal_Error in Ubuntu's source of xlsfonts/dsimple.c.

Are the others your own creation? Then we should adjust the END FROM marker.

Even better would be to write our own Fatal_Error function as well, because I can't currently see license compatibility.

Maybe it would suffice to have Fatal_Error be a trivial function that just prints the error message, and a comment for where to find a fancier function (e.g. the Ubuntu link above) if someone wants to make a temporary debug build.

Intent to package: Snaps are universal Linux packages

Dear maintainer(s),

Snaps are universal Linux packages that can be installed and run on many GNU+Linux distributions with ease. I've been following the Snapcrafters instructions and have built a working snap on the Snap Store, you may try it by running the following commands after installing snapd:

sudo snap install xseticon

I'm also looking forward to working with you to make the packaging work upstream (if you're interested). You may want to check out the current packaging recipe, the documentation, registering a developer account on the Snap Store, and get in touch with us to transfer the work under your control.

Thanks for your time and attention.

Result seems OK but icon is not set

image

I just want to substitute the default "gnome-terminal" icon with a custom PNG...

I am executing this

./xseticon -id 0x08208e70 /home/ricciolino/.local/share/pixmaps/dmesg.png

Result seems ok .... but icon of gnome-terminal is not changed...

image

Why this ?

Order of abortprog("XOpenDisplay")

Hi! Thanks for writing this program. A tool like this should be shipped with Xorg by default, IMO.

Why do you have the abortprog("XOpenDisplay"); check only after display has already been used in XSynchronize and int screen =?

does not work under Debian 10.2

xseticon installed from snap package on Debian 10.2

I'm trying to set the icon for a Chrome window running JupyterLab

xwininfo reports Window id: 0x460015a "JupyterLab"

$ xseticon -id 0x460015a /tmp/jupyter.png 
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Aborted at function fopen()
$ xseticon -name "JupyterLab" /tmp/jupyter.png 
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
xseticon: error: No window with name JupyterLab exists!

The specified png file does exist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.