After some struggle I have compiled the PHP module for wxPHP, and am writing a few scripts to see what it can do. My first demo creates a window and a task bar icon, and I cannot get the latter to work.
I am running this on Ubuntu 14.04 LTS.
Here is the script I am using:
<?php
// Create an icon (does not appear on Ubuntu 14.04 LTS)
$icon = new wxTaskBarIcon();
echo "Task bar available: " .
(wxTaskBarIcon::IsAvailable() ? 'Yes' : 'No') . "\n";
echo "Create task bar icon: " . ($icon ? 'OK' : 'Failed') . "\n";
$wxIcon = new wxIcon('icon.ico');
$ok = $icon->setIcon($wxIcon);
echo "Set image for icon: " . ($ok ? 'OK' : 'Failed') . "\n";
// Create a window (works fine)
$main = new wxFrame(null, wxID_TOP, "Title" );
$main->Show();
wxEntry();
Now, I would imagine the "task bar" in Unity is the top bar featuring the clock, sound and networks controls, and not the app dock on the left hand side. I do get a blank grey app icon in the dock, when the PHP task is running, but it's a status icon at the top I am after.
The console outputs from the above script show everything is OK:
Task bar available: Yes
Create task bar icon: OK
Set image for icon: OK
I have tried changing the icon.ico
to a non-existent file, and this pops a backtrace dialogue, which shows that the icon I am using is loading successfully (and presumably of an acceptable format).
Edit: further research indicates that:
gsettings
keys referenced here are not found in my later version of Ubuntu)Thus, my guess at present is that my code would work if it was not for Unity preventing the operation - and that it would immediately in other distros such as Mint.
I did find this guide that explains how to whitelist on Ubuntu 14, but this is most unsatisfying; to do something so trivial one should not need to alter the trusted repo list. If I wish to distribute an application written in wxPHP, users will (and should) find this unacceptable.
There are a couple of avenues for research, which I am now seeking advice upon:
Edit again: since this is a rather niche question, and since Ask Ubuntu carries a number of programming-related questions for the Ubuntu platform, I have asked a DBus-specific question over on that site.
Broadly, it's not possible to create a taskbar icon on Ubuntu, at least via wxPHP or wxWidgets. This is a deliberate design decision from the Ubuntu usability team to introduce consistency and accessibility into the use of application-level status icons.
I raised this as a bug and obtained a lot of very useful information from the maintainer of wxPHP. I agree with him that this feature would be better upstream in wxWidgets, but from comments online it does not seem there is much appetite to add it there.
My short-term solution will be to set up a Python process to use its own App Indicator (python-appindicator
in the Ubuntu repo) and communicate between the two processes (PHP to Python to change the icon, Python to PHP to send menu choice events). I expect to start with I'll be using wxFileSystemWatcher
as a simple communication system, since ths works well inside the wxWidgets event loop.
A better solution would be to have appindicator
bindings for PHP, but that sounds more involved, so I will leave that for now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With