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?
Asked
Active
Viewed 2,138 times
8
-
1The quick method is to toggle fullscreen (of the window in focus) with `F11`. – sudodus Aug 05 '20 at 09: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 05 '20 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 05 '20 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 05 '20 at 16:14
1 Answers
11
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 [email protected]
for enabling back
gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.EnableExtension [email protected]
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 [email protected] | 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 [email protected]
else
gdbus call --session --dest org.gnome.Shell.Extensions --object-path /org/gnome/Shell/Extensions --method org.gnome.Shell.Extensions.EnableExtension [email protected]
fi
Below GIF shows the result. However, when gnome-shell refreshes/re-login/reboot etc. will affect the persistence.
Pablo Bianchi
- 14,308
- 4
- 74
- 117
PRATAP
- 21,989
- 8
- 59
- 121
-
1+1 worked up until 20.04. Now hiding the panel just returns `(false, '')`, same with trying to show. Does anyone know why? – Zany_Zachary1 Mar 21 '22 at 14:55
