Skip to content

Commit

Permalink
Added Power Options and improved list order
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryan20 committed Sep 14, 2021
1 parent 5d9a882 commit 5a607dc
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 21 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Logo Menu


<img src="https://github.com/Aryan20/Logomenu/blob/main/screenshot2.png" width=259>
<img src="https://github.com/Aryan20/Logomenu/blob/main/screenshot2.png" width=410>

<img src="https://github.com/Aryan20/Logomenu/blob/main/screenshot1.png" width=375>

Expand All @@ -18,18 +18,20 @@ Join the matrix room for the latest news and releases and/or for suggestions: [c

-System Settings

-Software Center (defaults to `gnome-software`)

-Activities (this menu does replace the Activities button, but this option does leave that functionality easily accessible.)

-App Grid (Opens GNOME app menu/grid)

-Force Quit App (run this and select the app you want to kill. Requires `xkill` )
-Software Center (defaults to `gnome-software`)

-Terminal (defaults to `gnome-terminal`)

-Extensions (Quick access to all of your GNOME Extensions.)

-Force Quit App (run this and select the app you want to kill. Requires `xkill` )

-Power Options

fork of [Tofu Menu by tofutech](https://github.com/tofutech/tofumenu)

Compatible with and tested on GNOME 40 and 41. Should work on older versions.
Expand Down
77 changes: 62 additions & 15 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ function _overviewToggle() {
Main.overview.toggle();
}

function _sleep() {
Util.spawn(['systemctl', 'suspend'])
}

function _restart() {
Util.spawn(['systemctl', 'reboot'])
}

function _shutdown() {
Util.spawn(['systemctl', 'poweroff', '-prompt'])
}

function _logOut() {
Util.spawn(['gnome-session-quit'])
}

function _appGrid() {
// Code snippet from - https://github.com/G-dH/custom-hot-corners-extended/blob/gdh/actions.js
// Pressing the apps btn before overview activation avoids icons animation in GS 3.36/3.38
Expand Down Expand Up @@ -62,30 +78,43 @@ var MenuButton = GObject.registerClass(class FedoraMenu_MenuButton extends Panel
})
this._settings.connect("changed::menu-button-icon-image", () => this.setIconImage())
this._settings.connect("changed::menu-button-icon-size", () => this.setIconSize())

this.setIconImage()
this.setIconSize()
this.add_actor(this.icon)

// Menu
this.item1 = new PopupMenu.PopupMenuItem(_('About My System '))
this._settings.connect('changed::show-power-options', () => this.togglePowerOptions())
this.togglePowerOptions();

//bind middle click option to toggle overview
this.connect('button-press-event', _middleClick.bind(this));
}

togglePowerOptions(){
let cstate = this._settings.get_boolean('show-power-options')
this.menu.removeAll()
this.item1 = new PopupMenu.PopupMenuItem(_('About My System '))
this.item2 = new PopupMenu.PopupMenuItem(_('System Settings...'))
this.item3 = new PopupMenu.PopupSeparatorMenuItem()
this.item4 = new PopupMenu.PopupMenuItem(_('Activities'))
this.item5 = new PopupMenu.PopupMenuItem(_('App Grid'))
this.item6 = new PopupMenu.PopupMenuItem(_('Force Quit App'))
this.item7 = new PopupMenu.PopupSeparatorMenuItem()
this.item8 = new PopupMenu.PopupMenuItem(_('Software Center...'))
this.item9 = new PopupMenu.PopupMenuItem(_('Terminal'))
this.item10 = new PopupMenu.PopupMenuItem(_('Extensions'))

this.item5 = new PopupMenu.PopupMenuItem(_('App Grid'))
this.item6 = new PopupMenu.PopupSeparatorMenuItem()
this.item7 = new PopupMenu.PopupMenuItem(_('Software Center...'))
this.item8 = new PopupMenu.PopupMenuItem(_('Terminal'))
this.item9 = new PopupMenu.PopupMenuItem(_('Extensions'))
this.item10 = new PopupMenu.PopupSeparatorMenuItem()
this.item11 = new PopupMenu.PopupMenuItem(_('Force Quit App'))

this.item1.connect('activate', () => _aboutThisDistro())
this.item2.connect('activate', () => _systemPreferences())
this.item4.connect('activate', () => _overviewToggle())
this.item5.connect('activate', () => _appGrid())
this.item6.connect('activate', () => _forceQuit())
this.item8.connect('activate', () => this.softwareStore())
this.item9.connect('activate', () => this.terminal())
this.item10.connect('activate', () => this.extensions())
this.item7.connect('activate', () => this.softwareStore())
this.item8.connect('activate', () => this.terminal())
this.item9.connect('activate', () => this.extensions())
this.item11.connect('activate', () => _forceQuit())

this.menu.addMenuItem(this.item1)
this.menu.addMenuItem(this.item2)
this.menu.addMenuItem(this.item3)
Expand All @@ -96,9 +125,27 @@ var MenuButton = GObject.registerClass(class FedoraMenu_MenuButton extends Panel
this.menu.addMenuItem(this.item8)
this.menu.addMenuItem(this.item9)
this.menu.addMenuItem(this.item10)

//bind middle click option to toggle overview
this.connect('button-press-event', _middleClick.bind(this));
this.menu.addMenuItem(this.item11)
if (cstate) {
this.item11 = new PopupMenu.PopupSeparatorMenuItem()
this.item12 = new PopupMenu.PopupMenuItem('Sleep')
this.item13 = new PopupMenu.PopupMenuItem('Restart')
this.item14 = new PopupMenu.PopupMenuItem('Shut Down')
this.item15 = new PopupMenu.PopupSeparatorMenuItem()
this.item16 = new PopupMenu.PopupMenuItem('Log Out...')

this.menu.addMenuItem(this.item11)
this.menu.addMenuItem(this.item12)
this.menu.addMenuItem(this.item13)
this.menu.addMenuItem(this.item14)
this.menu.addMenuItem(this.item15)
this.menu.addMenuItem(this.item16)

this.item12.connect('activate', () => _sleep())
this.item13.connect('activate', () => _restart())
this.item14.connect('activate', () => _shutdown())
this.item16.connect('activate', () => _logOut())
}
}

terminal() {
Expand Down
40 changes: 38 additions & 2 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ var FedoraMenuPreferencesWidget = GObject.registerClass(class Fedora_Menu_Prefer
this.append(menuButtonTerminalFrame);
}



let menuButtonSCFrame = new Gtk.Frame();
let menuButtonSCBox = new Gtk.Box({
margin_top: 5,
Expand Down Expand Up @@ -239,6 +237,44 @@ var FedoraMenuPreferencesWidget = GObject.registerClass(class Fedora_Menu_Prefer
menuButtonSCFrame.set_child(menuButtonSCBox);
this.append(menuButtonSCFrame);
}

let PowerOptionFrame = new Gtk.Frame();
let PowerOptionBox = new Gtk.Box({
margin_top: 5,
margin_bottom: 5,
margin_start: 5,
margin_end: 5,
});

let enablePowerOptionText = new Gtk.Label({
label: _("Enable Power Options"),
use_markup: true,
xalign: 0,
hexpand: true
})

let showPowerOptionsSwitch= new Gtk.Switch({
halign: Gtk.Align.END,
});

showPowerOptionsSwitch.set_active(this._settings.get_boolean('show-power-options'));
showPowerOptionsSwitch.connect('notify::active', (widget) => {
this._settings.set_boolean('show-power-options', widget.get_active());
});

if (shellVersion < 40){
PowerOptionBox.add(enablePowerOptionText);
PowerOptionBox.add(showPowerOptionsSwitch);
PowerOptionFrame.add(PowerOptionBox);
this.add(PowerOptionFrame);
}
else{
PowerOptionBox.append(enablePowerOptionText);
PowerOptionBox.append(showPowerOptionsSwitch);
PowerOptionFrame.set_child(PowerOptionBox);
this.append(PowerOptionFrame);
}

}
})

Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
6 changes: 6 additions & 0 deletions schemas/org.aryan_k.logo-menu.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<description>Change the Menu Button Terminal.</description>
</key>

<key type="b" name="show-power-options">
<default>false</default>
<summary>Toggle power options vsibility</summary>
<description>Toggle power options vsibility.</description>
</key>

</schema>

</schemalist>
Binary file modified screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a607dc

Please sign in to comment.