morgant / xsndiomenu

An X11 menu to control sndiod(8) under OpenBSD
MIT License
4 stars 0 forks source link

Implement icon that can be swallowed into mlvwm menu bar to open xsndiomenu #1

Open morgant opened 11 months ago

morgant commented 11 months ago

Since I primarily use MLVWM with the mlvwmrc configuration, I'd like a more Mac-like way to open xsndiomenu. Preferably, a MenuExtra-like icon that can be 'swallowed' into the mlvwm menu bar.

My wishlist includes:

morgant commented 11 months ago

I discovered that Lucas de Sena, the developer of xmenu which xsndiomenu uses to render its X11 menu, also has a utility named wmlaunchbutton which can render an pixmap (XPM) that clicking on will launch a command. There's not currently a packaged port for OpenBSD, but it builds and runs successfully using the included Makefile.

In my testing, it can easily be swallowed into the mlvwm menu bar, supports different icons for normal/hover/active state, and launches xsndiomenu on each click. It also sets an BUTTON_GEOMETRY environment variable with the icon's width, height, and x/y offset, which would likely make it possible to position xsndiomenu's menu at the bottom-left of the icon.

I was able to track down the FamFamFam Silk icons (circa 2006) and it has nice, color, 16x16 PNGs of full/low/none/muted speaker. They were easily converted to XPM using ImageMagick's convert and look good enough for initial use. Plus, they're released under a Creative Commons by-attribution license.

The one thing I'm not currently sure about is whether I can dynamically change the wmlaunchbutton icon while it's swallowed into the mlvwm menu bar. OpenBSD's sndioctl(1) has a -m option that will keep running and print controls as they change, so that should allow me to easily detect when to change the icon, but wmlaunchbutton itself doesn't appear to have a way to change the icon post-launch. I can easily relaunch wmlaunchbutton with a different icon, but since the X11 window will close, I'm expecting that it will disappear from the mlvwm menu bar.

morgant commented 11 months ago

I've got a WIP xsndioicon script which watches & parses sndioctl -m output and relaunches wmlaunchbutton with the appropriate icon. I've got to get it tested w/swallowing into the mlvwm menu bar to see if it works.

morgant commented 11 months ago

I've now committed the initial version of an xsndioicon utility which watches sndioctl -m output and displays the clickable status icon via wmlaunchbutton.

I'm still experimenting with getting mlvwm to even swallow the wmlaunchbutton window.

morgant commented 11 months ago

I've been testing a bit more with swallowing wmlaunchbutton into the menu bar with mlvwm and have it working directly. I've added an mlvwmrc MenuExtra configuration, plus install-mlvwmrc-menuextra & uninstall-mlvwmrc-menuextra targets in the Makefile.

Since I'm using wmlaunchbutton & xsndiomenu directly, instead of the experimental xsndioicon which relaunches wmlaunchbutton as a background process, I'm currently using just a static sound icon. I did have a discussion with Lucas de Sena on Mastodon regarding dynamically changing wmlaunchbutton icons via X resources, so will be opening an issue and trying to implement that soon. In the meantime, I'll likely strip the fancy functionality out of xnsdioicon for a release, then reintroduce it in a later version.