3

I want a shortcut to hide the top bar and dock, so I thought the best way to do that would be to figure out a terminal command which does the same.So, can someone tell me the command to do so or another way to make the shortcut work?

  • 1
    The quick method is to toggle fullscreen (of the window in focus) with F11. – sudodus Aug 5 at 9:10
  • @PRATAP I don't know what gnome-shells-dock is but I'm just using the default ubuntu setup. I haven't installed dock extensions and stuff – Heisenberg Aug 5 at 16:08
  • 1
    @sudodus I know about that but some applications like nautilus won't go fullscreen with F11. You can use Ctrl+Super+M to make them fullscreen but I don't want to make every application fullscreen one by one. – Heisenberg Aug 5 at 16:10
  • Nah, I'm dock is the normal dock (Its's probably Ubuntu Dock I suppose). As I told you I haven't installed any extension to make the dock like that – Heisenberg Aug 5 at 16:14
7

This command can be used to hide the topbar

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval string:'Main.panel.actor.hide();'

to show it back

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval string:'Main.panel.actor.show();'

You can tweak the commands with a script to toggle show and hide.


For Ubuntu dock hiding - the below workaround is a bit overkill because we are disabling the whole extension.

gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.DisableExtension ubuntu-dock@ubuntu.com

for enabling back

gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.EnableExtension ubuntu-dock@ubuntu.com

You can tweak the commands with a script to toggle Enabling and Disabling

All together you can have a single keyboard shortcut that can toggle "Hiding the Topbar and disabling the Extension" "Showing the Topbar and Enabling the Extension"

you can create a script with below content..

#!/bin/bash

status1=`gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval string:'Main.panel.actor.visible;'`
status2=`gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.GetExtensionInfo ubuntu-dock@ubuntu.com | grep "'state': <2.0>" >/dev/null && echo "OFF" || echo "ON"`


if [ "$status1" == "(true, 'false')" ]; then
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.panel.actor.show();'
else
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.panel.actor.hide();'
fi

if [ "$status2" == "ON" ]; then
gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.DisableExtension ubuntu-dock@ubuntu.com
else
gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.EnableExtension ubuntu-dock@ubuntu.com
fi

Below GIF shows the result. However when gnome-shell refreshes/re-login/reboot etc will affect the persistence.

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.