Can't install Window AppMenu Applet

Solution 1:

The cmake command is needed to build that code, and you don't have it. This, rather than the [: -a: unexpected operator message, appears to be what is actually keeping your build from continuing. So first install cmake. Some software needs a very new version of cmake to build (which you can install if you need to) but most does not. I recommend you install the cmake package.

While you're at it, it's a good idea to make sure you have the usual toolchain for building programs on your Ubuntu system, too, which the build-essential package will get you.

These commands will install both cmake and those other tools:

sudo apt update
sudo apt install build-essential cmake

This will likely be sufficient to enable you to successfully build the software, or at least to get past the current error you're facing. However, I recommend you delete the build directory and its contents before proceeding:

rm -r build

After further troubleshooting steps that involve installing or removing software or editing files from the source code (or, if you like, even every time you build the source code), I recommend removing the build directory and starting fresh.

The messages you're getting about -a are probably not stopping the build from succeeding. You can probably ignore them. They also would likely go away if you used bash instead of sh, though I don't think that's the best solution. If you want to get rid of them or you suspect they are causing a problem then you can either edit the install.sh script to use the appropriate test (or no test) or you can manually perform the actions that script performs. So if you want to do something about this, see below for the details.


In the source code for both applet-window-buttons and applet-window-appmenu, install.sh currently has this as its complete contents:

if ! [ -a build ] ; then
    mkdir build
fi
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr .. -Wnodev
make
sudo make install

This is the file you are attempting to run with sh that is producing errors. Its use of the -a test is very strange. -a typically appears between two other expressions, and causes [ to return true when both expressions are true.

In Ubuntu, sh is provided by dash. If you use bash instead of dash, it may work (or appear to work). Perhaps that's what the authors did. However, instead of doing that, I recommend you either fix the script or just manually do what it does.

If you want to fix the script, one way would be to replace -a with -e or -d. The -e test takes a filename operand and checks if it exists; -d checks if it exists and is a directory. Another way to fix the script would just be to remove the if and fi lines entirely; mkdir would fail if the directory exists, but that's no problem.

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr .. -Wnodev
make
sudo make install

But all this script does is create a build directory if there isn't one, change into it with cd, run cmake with some arguments, run make, and then run sudo make install. You can just do these things yourself. One way to do so is to run those commands in your interactive shell, one after another.

This has advantages. As written, the script doesn't stop just because some step reports failure, but you probably would want to stop. You could make further modifications to the script to achieve that (perhaps ending each line except the first and last with &&) but it's probably easier to just run the commands yourself if you're not planning on compiling the code numerous times.

Solution 2:

I was also facing some issues. Managed to build it on Kubuntu 21.04. Following should be kept in mind

  • Delete the build/ folder in subsequent build attempts
  • Install the dependencies. This can be referred.
  • Do make sure gcc, cmake etc. are not conflicting
  • After the install, the widget appears in the "add widget" option on panel