How do i write a gnome extension in ubuntu 20.04 that removes the shutdown/logout menu seen in the screenshot with the red line......i cant find any documentation on it :?.
1 Answers
this link https://wiki.gnome.org/Projects/GnomeShell/Extensions/Writing provides the useful information.
For a quick workaround to remove the Poweroff/Logout Menu in the Question, do the following steps..
run the below commands to create new extension ("remove_poweroff-logout_menu@username.domain") directory and required files. change what ever the name you want replacing "remove_poweroff-logout_menu@username.domain
" in below command.
run
install -D /dev/null $HOME/.local/share/gnome-shell/extensions/remove_poweroff-logout_menu@username.domain/extension.js
run
install -D /dev/null $HOME/.local/share/gnome-shell/extensions/remove_poweroff-logout_menu@username.domain/metadata.json
copy paste the below content in extension.js
file
'use strict';
const Main = imports.ui.main;
const Menu = Main.panel.statusArea.aggregateMenu._system.menu;
class Extension {
constructor() {
}
enable() {
Menu.actor.remove_child(Main.panel.statusArea.aggregateMenu._system._sessionSubMenu);
}
disable() {
Menu.box.insert_child_at_index(Main.panel.statusArea.aggregateMenu._system._sessionSubMenu, Main.panel.statusArea.aggregateMenu._system.menu.numMenuItems)
}
}
function init() {
return new Extension();
}
copy paste the below content in metadata.json
file. Replace remove_poweroff-logout_menu@username.domain
with the same name that you have created for the extenson's directory in below content. I have tested this extension in gnome-shell version 3.38, if you are testing different versions, you can edit shell-versions in below contents.
{
"name": "Remove Poweroff/Logout Menu",
"description": "Remove Poweroff/Logout Menu",
"uuid": "remove_poweroff-logout_menu@username.domain",
"shell-version": [
"3.38"
]
}
Save the files & close..
If you are on Xorg session. you can refresh the gnome-shell with Alt+F2 r Enter method and then turn on the extension.
If you are on Wayland session. logout and login and then turn on the extension.

- 22,460
-
1Many thanks :), this works great :) – Anders Andersen Feb 19 '21 at 08:27