Compile Unity without launcher
I would like to modify unity to not show the launcher (left side bar) at all. I'm not looking for any solution that would let the launcher be in some cases visible. I really want it to completly disappear. It's a gift for my fiance and I want to achieve the highest possible Woman Acceptance Factor for her linux laptop which is running a docky dock with fancy icons that make it look like being from that known and fruity company.
Any hints about which packages and which source files I should study?
I'm hoping it to be as easy as commenting out the line with "unity.launcher.show()" and recompiling :-)
Thank you!
The answer to my own question is:
- Launcher.cpp, unityshell.cpp, DashController.cpp and HudController.cpp for unity version < 7.4.0 and
- Launcher.cpp and UnitySettings.ccp for unity version 7.4.0
from the unity source package.
But I'm answering more than that since everybody looking for the answer to my question will also be interested in knowing what to do with those source files.
Contents:
A. Compile yourself or
B. Get the binary
Disclaimer: I have no clue AT ALL and this was tested only on 12.04 with unity 5.20.2, on 14.04 with unity 7.2.6, on 15.10 with unity 7.3.2, and on 16.04 with unity 7.4.0
A. Compile Unity to not show the launcher
0. For the impatience
This script should work at least for 12.04, 14.04 and 15.10. Just uncomment at the end as needed:
#!/bin/bash
mkdir temp-build-dir; cd temp-build-dir
export HWE=$(dpkg-query -l xserver*-lts-* | grep ^ii | cut -d" " -f3 | rev | cut -d- -f1 | rev | sort -u)
sudo apt-get install unity xserver-xorg-video-dummy-lts-$HWE
sudo apt-get build-dep unity
sudo apt-get install apt-show-versions devscripts dpkg-dev fakeroot nano
apt-get source unity
cd unity-*
# you can leave the comment field in the changelog empty but dont forget to save the file
EDITOR=nano debchange --newversion $(apt-show-versions unity | cut -d " " -f2)
find . -iname Launcher.cpp -exec sed -i -e '1,/void Launcher::DrawContent(nux::GraphicsEngine/b' -e '0,/{/s//{\nreturn;/' {} \;
# for unity 7.4.0 comment out this for statement and read the explanation Nr. A.4
for i in unityshell.cpp DashController.cpp HudController.cpp; do
find . -iname $i -exec sed -i -e 's/launcher_width =/launcher_width =0; \/\//' {} \;
done
dpkg-buildpackage -rfakeroot -d -us -uc -b
sudo dpkg -i ../unity_*.deb
# For 12.04 use:
# gconftool --type Integer --set /apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode 1
# For 14.04 use:
# dconf write "/org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode" 1
Then restart unity and you're done.
1. Look for the right source files
After some trial and error I found out that the source files to be changed are
- Launcher.cpp -> add one line to not show the launcher anymore
- unityshell.cpp, DashController.cpp and HudController.cpp -> set the width of the launcher to zero
All four files are contained in the source package "unity".
2. Get the sources
I had to install the package xserver-xorg-video-dummy-lts-{your HWE version} manually to fulfill some dependency problems before being able to install the build-deps for unity:
sudo apt-get install xserver-xorg-video-dummy-lts-{put your HWE name here}
You can find the name (version) of your HWE with this command:
dpkg-query -l xserver*-lts-* | grep ^ii | cut -d" " -f3 | rev | cut -d- -f1 | rev | sort -u
After that the rest worked:
sudo apt-get build-dep unity
apt-get source unity
cd unity-*
3. Put one line in Launcher.cpp
find . -iname launcher.cpp -exec gedit {} \;
Look for the function "void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)" and put a "return;" just at its body's begin like this:
void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
{
return; //dont show launcher anymore
...
This is enough to not show the launcher anymore. But the dash and hud will stil leave the place for the launcher at the left side of the screen unused.
4. Set the launcher width to zero in unityshell.cpp, DashController.cpp and HudController.cpp / UnitySettings.cpp
For unity < 7.4.0:
Use an editor to replace all occurences of "launcher_width =" with "launcher_width =0; //" in unityshell.cpp, DashController.cpp and HudController.cpp.
Or just use this command
for i in unityshell.cpp DashController.cpp HudController.cpp; do find . -iname $i -exec sed -i -e 's/launcher_width =/launcher_width =0; \/\//' {} \; ; done
For unity 7.4.0:
Find the file UnitySettings.cpp and replace the return value at the end of LauncherSize like this:
int Settings::LauncherSize(int monitor) const
{
if (monitor < 0 || monitor >= (int)monitors::MAX)
{
LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Returning 0.";
return 0;
}
return 0; // pimpl->launcher_sizes_[monitor];
}
This is needed only if you want the dash to be shown right at the left side of the screen, without any margin that would have been used by the launcher.
5. Set the right version in the changelog
In my case (12.04, unity 5.20.2) I had to change the version of the source of unity from 5.20 to 5.20.2 using
EDITOR=nano debchange --newversion $(apt-show-versions unity | cut -d " " -f2)
before compiling to avoid having broken dependencies when installing. Don't forget to save the file.
6. Compile and install
Then I recompiled using this:
dpkg-buildpackage -rfakeroot -d -us -uc -b
Installed the new package:
sudo dpkg -i ../unity_*.deb
(As far as I can see and test it, the only file actually needed is
find . -name libunityshell.so | grep unity/usr/lib/compiz/libunityshell.so
Replacing /usr/lib/compiz/libunityshell.so with that new one should be enough, but if you want to be sure just install the new unity package as written above.)
7. Set the launcher to autohide
# For 12.04:
gconftool --type Integer --set /apps/compiz-1/plugins/unityshell/screen0/options/launcher_hide_mode 1
# For 14.04:
dconf write "/org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode" 1
That's it. Restarted unity and the launcher went away!
B. In case you prefer to trust and just get the binary
If you prefer to get the binary and your combination of unity version and PC architecture
unity --version
getconf LONG_BIT
can be found below, just download the right package
32bit
- unity_5.20.0-0ubuntu3_i386_nolauncher.deb
- unity_5.20.2_i386_nolauncher.deb
- unity_7.2.6+14.04.20151021-0ubuntu1_i386_nolauncher.deb
- unity_7.3.2+15.10.20151016-0ubuntu1_i386_nolauncher.deb
64bit
- unity_5.20.0-0ubuntu3_amd64_nolauncher.deb
- unity_7.2.6+14.04.20160408-0ubuntu1_amd64_nolauncher.deb
- unity_7.3.2+15.10.20151016-0ubuntu1_amd64_nolauncher.deb
- unity_7.4.0+16.04.20160715-0ubuntu1_amd64_nolauncher.deb
and check the deb file after download
md5sum unity_*.deb
The result should be one of these
0a5f7fc9255262e5803656d83f84f7c5 unity_5.20.0-0ubuntu3_amd64_nolauncher.deb
717dc41f4cad6410c997e1014f5f3f1d unity_5.20.0-0ubuntu3_i386_nolauncher.deb
594eb8b87f8a56697865c051c4db5073 unity_5.20.2_i386_nolauncher.deb
8ed070afa4d7d6da8222d03b8ad5ebf3 unity_7.2.6+14.04.20160408-0ubuntu1_amd64_nolauncher.deb
abd32e40e8a10bd603b9fc44014cb179 unity_7.2.6+14.04.20151021-0ubuntu1_i386_nolauncher.deb
43c56b889028bf368da01780c0a099b9 unity_7.3.2+15.10.20151016-0ubuntu1_amd64_nolauncher.deb
64474d1a8280ed4113d748a57422ddcc unity_7.3.2+15.10.20151016-0ubuntu1_i386_nolauncher.deb
4fecdb9b4f590e00609baa3b98f55cc0 unity_7.4.0+16.04.20160715-0ubuntu1_amd64_nolauncher.deb
Then install the package
sudo dpkg -i unity_*.deb
set the launcher to auto-hide and restart unity. That's it!
In case something goes wrong and unity doesn't start:
sudo apt-get install --reinstall unity
But if everything works, you might want to prevent the new package from being updated:
echo "unity hold" | sudo dpkg --set-selections
Only the file "unity_5.20.2_i386_nolauncher.deb" was compiled on my PC. The other deb files were made on so called "cloud computers" (because machine rooms look so much like clouds...) using this variation of the script:
#!/bin/bash
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y build-dep unity
sudo apt-get -y install unity devscripts dpkg-dev fakeroot nano
mkdir temp-build-dir; cd temp-build-dir
rm -r unity-*
apt-get source unity
cd unity-*
find . -iname Launcher.cpp -exec sed -i -e '1,/void Launcher::DrawContent(nux::GraphicsEngine/b' -e '0,/{/s//{\nreturn;/' {} \;
# for unity 7.4.0 comment out this for statement and read the explanation Nr. A.4
for i in unityshell.cpp DashController.cpp HudController.cpp; do
find . -iname $i -exec sed -i -e 's/launcher_width =/launcher_width =0; \/\//' {} \;
done
dpkg-buildpackage -rfakeroot -d -us -uc -j2 -b
cp ../unity_*.deb ../$(echo ../unity_*.deb | sed -e 's/.deb$/_nolauncher.deb/')