Like many things, it does not exist as far as I know, BUT, it can be done with a little creativity and the right tools.
How it can be done
Assuming you are on 14.04 (with python3), you can use a script to run in the background, that keeps track of your current viewport and sets the launcher to autohide or not, depending on that current viewport.
What you need to do first is install
sudo apt-get install wmctrl
wmctrl to get information about the total size of all viewports and to be able to read information about the current section we are in.
Once that is done, copy the script below into an empty file and safe it as
autohide_launcher.py (keep the name like that) and make it executable(!).
In the line
hide_launcher, decide for wich viewports you want to autohide the launcher (set "True"), and use the correct number of entries, corresponding with your number of viewports. The list reads per viewport row, from left to right.
# set the hide-launcher values for your viewports; in rows/columns
hide_launcher = (False, True, True, True)
# don't change anything below (or it must be the time.sleep(2) interval)
key = " org.compiz.unityshell:/org/compiz/profiles/unity/plugins/unityshell/ "
pr_get = "gsettings get "; pr_set = "gsettings set "
check = pr_get+key+"launcher-hide-mode"
hide = pr_set+key+"launcher-hide-mode 1"
show = pr_set+key+"launcher-hide-mode 0"
["/bin/bash", "-c", command]).decode('utf-8').strip()
# get screen resolution
output = get_value("xrandr").split(); idf = output.index("current")
screen_res = (int(output[idf+1]), int(output[idf+3].replace(",", "")))
# get total span size all viewports, position data
wsp_info = get_value("wmctrl -d").strip()
scr_data = [item.split("x") for item in wsp_info.split(" ") if "x" in item]
# get current position (viewport coordinates)
VP = eval(wsp_info[wsp_info.find("VP: "):].split(" "))
# calculated viewports rows / columns
VP_hor = int(scr_data)/int(screen_res)
VP_vert = int(scr_data)/int(screen_res)
# calculated viewport positions
range_hor = [i*screen_res for i in range(int(VP_hor))]
range_vert = [i*screen_res for i in range(int(VP_vert))]
viewports = [(h, range_vert[i])for i in range(len(range_vert)) for h in range_hor]
current_viewport = viewports.index(VP); a_hide = get_value(check)
if (hide_launcher[current_viewport], a_hide == "0") == (True, True):
subprocess.Popen(["/bin/bash", "-c", hide])
elif (hide_launcher[current_viewport], a_hide == "0") == (False, False):
subprocess.Popen(["/bin/bash", "-c", show])
Toggle autohide-per-viewport on/of
However, it is more convenient to use the script below to have one command to toggle the script on/of.
Copy the script below into an empty file and save it as
start_stop.py, in one and the same folder as the
autohide_launcher.py script. Make it executable as well(!). Now you can toggle the autohide function with the command
The start/stop script:
script_dir = os.path.dirname(os.path.abspath(__file__))
cmd = "ps -ef | grep autohide_launcher.py"
run = subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8").split("\n")
match = [line for line in run if script_dir+"/"+"autohide_launcher.py" in line]
if len(match) != 0:
subprocess.Popen(["notify-send", "autohide per viewport stopped..."])
subprocess.Popen(["/bin/bash", "-c", script_dir+"/"+"autohide_launcher.py"])
subprocess.Popen(["notify-send", "autohide per viewport started..."])
Alternative ways to start or stop the script
There are several other ways to toggle the script in a convenient way:
Add the script to your startup apoplications
If you permanently want to run the script in the background:
Set a keyboard shortcut to toggle the script
- Open System Settings and choose: "Keyboard" > "Shortcuts" > "Custom Shortcuts".
Create a new shortcut of your choice, with the command:
Now you can toggle autohide-per-viewport with the key combination.
posted on gist.gisthub
Setting a different Unity Launcher per workspace:
1. 2. 3. 4.
The solution below makes it easily possible to have a different set of launcher icons per workspace, no matter how many workspaces you have.
The setup includes two parts:
A (one) shortcut key combination to "remember" the set of launcher icons for the current workspace.
A script to run in the background, keeping track of what is the current workspace and setting the corresponding Unity Launcher. It acts whenever the user switches workspace.
How it works
Two small scripts are involved:
The first script does one simple thing: it writes the contents of the current launcher into a (hidden) file in your home directory, named (numbered) after your current workspace.
The second script keeps an eye on what is the current workspace. If there is a workspace change, the script sees if a corresponding (launcher-) datafile exists (created by the first script). If so, it reads the file and alters the Unity Launcher, as remembered in the file.
How to set up
The script needs
wmctrlto be installed:
Create a directory in which both scripts will be stored. It is importants that both scripts are kept together in one directory, since they share functionality and one imports from the other. For the same reason, it is important that you name them exactly as indicated below.
Copy each of the scripts below into a (different) empty file, save them into the directory (created in
2.), exactly named as:
Add the first script (
set_workspace.py) to a shortcut key combination of your choice: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:
Run the key combination and see if a file, like:
.launcher_data_3is created in your home directory. You will probably need to press Ctrl+H to make the file visible (files, starting with a
.are invisible by default).
Navigate through your workspaces and repeat the procedure: set a combination of launcher icons, and press your key combination to "remember" the set for that specific workspace.
You're practically done now. Test-run the background script with the command (from a terminal window, keep it running):
If all works fine, and your launcher switches per workspace, add the following command to your Startup applications: Dash > Startup Applications > Add:
From your comment, I understand that you are unsure to run the script(s) and you are afraid you will mess up your current launcher.
I am pretty sure that is too much (or too little :)) respect for what the script is doing. However, you can simply backup yor current Unity Launcher with the command:
This will create a file
~/launcher_output, containing the complete command to restore your Unity Launcher to the initial situation. In case of emergency, simply copy the file's content and paste it in the terminal.
But again, it is really unlikely you will mess up your launcher, unless you change the script manually.
IMPORTANT EDIT (2)
As requested in a comment, hereby a version that runs without having to use any shortcut combination; just run the script and start setting up your launchers on the specific workspaces. The script will create (invisible) files in your home directory, to remember your set of (Unity-) launchers on the different workspaces.
I tried this in "version 1" of the script, but always "embedding" the two launcher-checks between two workspace-checks turned out to be the trick to prevent unwanted behaviour (saving incorrect data) when moving quickly through the workspaces.
How to use
Like the first version, this script uses
sudo apt-get install wmctrl
Copy the script into an empty file, save it as
Run it with the command:
If it works as expected, add the following command to your Startup Applications:
If you set up your workspaces with the previous version of the script, they should also work for this version.
As per 2015-04-23, the nice question of Dennis J, and the encouragement of Parto, have lead to creating a
ppafor the script, covered on webupd8, including a GUI to manage it.
To install it, run:
Since now, it is packaged for Trusty & Utopic. I will add others after testing. I will also add a
.debinstaller, but I'd suggest using the
ppa, since usually this kind of things is updated every now and then.
Since the location of the viewport data has changed from
~/.config/lswitcher, you'll have to set up your Unity Launcher again if you used the previous script.