Skip to content
This repository was archived by the owner on Dec 31, 2019. It is now read-only.

Commit

Permalink
20170623 - Several minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
yafp committed Jun 23, 2017
1 parent eba97d8 commit 68ec01d
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 33 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Changelog
============

![logo](https://raw.githubusercontent.com/yafp/gnome-shell-extension-lock-my-desktop/master/.github/lock_icon.png)


## Version 0.x
* First extension version
* Tries locking via 'xscreensaver-command' and 'gnome-screensaver-command'
* Offers About dialog to access extension repository
* Supports gnome-shell version 3.18, 3.22 and 3.24

8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ DESTFOLDER=lock-my-desktop@yafp.de
DESTPATH=~/.local/share/gnome-shell/extensions/

install:
@mkdir -vp $(DESTPATH)/$(DESTFOLDER)
@install -v -m 0644 $(SRC)/* $(DESTPATH)/$(DESTFOLDER)
rm -rf $(DESTPATH)/$(DESTFOLDER)
mkdir -p $(DESTPATH)/$(DESTFOLDER)
cp -r --preserve=timestamps $(SRC)/* $(DESTPATH)/$(DESTFOLDER)
echo Installed in $(DESTPATH)/$(DESTFOLDER)


uninstall:
rm -rf $(DESTPATH)/$(DESTFOLDER)
echo Uninstalled $(DESTFOLDER) from $(DESTPATH)

21 changes: 21 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
Notes
============

![logo](https://raw.githubusercontent.com/yafp/gnome-shell-extension-lock-my-desktop/master/.github/lock_icon.png)


# Links
* https://stackoverflow.com/questions/13107743/documentation-for-writing-gnome-shell-extensions
* https://developer.gnome.org/gi/stable/
* http://mathematicalcoffee.blogspot.de/2012/09/gnome-shell-javascript-source.html

# Debug
## Log
Depending on your distro there are several places to check for log output

1. journalctl -f | grep gnome-session
2. journalctl -f /usr/bin/gnome-session
3. tail -f ~/.cache/gdm/session.log (GDM users)
4. tail -f ~/.xsession-errors


## Looking glass (GNOME Shell's integrated debugger and inspector )
You can see extensions and errors etc via Looking glass
* ALT+F2 -> lg
Expand All @@ -15,6 +35,7 @@ or to limit to a specific extension uuid via:


# Publishing
## http://extensions.gnome.org
* Upload extension on https://extensions.gnome.org/
* It should be a zip file containing at least the two files
* metadata.json and
Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
![logo](https://raw.githubusercontent.com/yafp/gnome-shell-extension-lock-my-desktop/master/.github/lock_icon.png)

# gnome-shell-extension-lock-my-desktop
Extension for gnome-shell to lock the desktop via the gnome panel
Extension for gnome-shell to lock the desktop via the gnome-shell panel

## Requirements
The `lock` function is using the `gnome-screensaver-command` with the `--lock` parameter.
The `lock` function is using the `xscreensaver-command` and/or the `gnome-screensaver-command` command with the `--lock` parameter.


## Supported gnome-shell versions
Expand All @@ -14,6 +14,10 @@ The extension was tested on the following `gnome-shell` versions.
- 3.24


## Changelog
The file [CHANGELOG.md](CHANGELOG.md) provides an overview of the major changes of this project; for a more detailed look at changes to the code, view individual commits.


## Howto
### Install
#### Version 1: Manual
Expand All @@ -35,3 +39,13 @@ The extension was tested on the following `gnome-shell` versions.
* Navigate to extracted archive
* Run `make uninstall`
* Restart Gnome-Shell (ALT+F2 -> r)


## Known Issues
### No screensaver
If your system has no configured screensaver the extension will most likely not work.


## Troubleshooting
Try running either `xscreensaver-command --lock` and/or `gnome-screensaver-command --lock` from your terminal.
If one of the above commands locks your desktop you should be fine.
17 changes: 17 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ToDo
============

![logo](https://raw.githubusercontent.com/yafp/gnome-shell-extension-lock-my-desktop/master/.github/lock_icon.png)


## Check lightbox.js
* Using lightbox to focus on menu when clicking it
* http://mathematicalcoffee.blogspot.de/2012/09/gnome-shell-javascript-source.html
* const ui = imports.ui
* const lightbox = imports.ui.lightbox


## Test Travis
Use travis to check if it builds
Ref: https://github.com/paradoxxxzero/gnome-shell-system-monitor-applet

96 changes: 74 additions & 22 deletions lock-my-desktop@yafp.de/extension.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
// Functions:
// Add a menu to the Gnome-Shell panel featuring a lock function (using gnome-screensaver-command)
//
// Icons: /usr/share/icons
// Name: Lock My Desktop
// Function: Add a menu to the Gnome-Shell panel featuring a lock function (using gnome-screensaver-command)
// Developer: yafp
// Github: https://github.com/yafp/gnome-shell-extension-lock-my-desktop
*/

const St = imports.gi.St;
Expand All @@ -11,13 +11,22 @@ const PopupMenu = imports.ui.popupMenu;
const PanelMenu = imports.ui.panelMenu;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Util = imports.misc.util; // to run external commands
const Util = imports.misc.util; // used to run external commands
const GLib = imports.gi.GLib; // used to check existance of executables

const Gettext = imports.gettext.domain("gnome-shell-extension-lock-my-desktop");
//const Gettext = imports.gettext.domain("gnome-shell-extension-lock-my-desktop");
const Gettext = imports.gettext.domain("lock-my-desktop");
const _ = Gettext.gettext;

const EXTENSION_NAME = "lock-my-desktop"; // Extension name
const EXTENSION_URL = "https://github.com/yafp/gnome-shell-extension-lock-my-desktop" // Extension URL
const EXTENSION_NAME = "lock-my-desktop"; // Extension name
const EXTENSION_URL = "https://github.com/yafp/gnome-shell-extension-lock-my-desktop"; // Extension URL


// Put your extension initialization code here
//function init(metadata) {
// Convenience.initTranslations();
//}


const ScrollableMenu = new Lang.Class({
Name: 'ScrollableMenu.ScrollableMenu',
Expand Down Expand Up @@ -80,13 +89,16 @@ const MainMenu = new Lang.Class({
Extends: PanelMenu.Button,

_init: function() {
global.log(EXTENSION_NAME + " - Initializing menu"); // log
this.parent(0.0, _("Menu"));
this.extensionIcon = new St.Icon({ icon_name: 'system-lock-screen-symbolic', style_class: 'popup-menu-icon' })
this.actor.add_actor(this.extensionIcon);
this._addConstMenuItems(); // add menu items to icon/button
},

_addConstMenuItems: function() {
global.log(EXTENSION_NAME + " - Adding menu items"); // log

// Menu: Lock
this.lock_item = new lockMyDesktopItem(_("Lock my desktop"), "system-lock-screen-symbolic", null, Lang.bind(this, this._onLock));
this.menu.addMenuItem(this.lock_item);
Expand All @@ -109,53 +121,93 @@ const MainMenu = new Lang.Class({
},


// Lock - Tries to lock the current desktop session using "gnome-screensaver-command --lock"
//
// ########################################################################
// Lock - Tries to lock the current desktop session
// ########################################################################
_onLock: function() {
//Util.spawn(['notify-send', 'Lock my desktop', 'Trying to lock your desktop now...']) // show notification
Util.spawn(['gnome-screensaver-command', '--lock']) // do the actual lock
global.log(EXTENSION_NAME + " - Starting _lock()"); // log

// v1: using xscreensaver-command --lock
//
var checkExistanceOfXScreensaverCommand=GLib.find_program_in_path('xscreensaver-command')
if(checkExistanceOfXScreensaverCommand == null)
{
global.log(EXTENSION_NAME + " - xscreensaver-command not in path or not found");
}
else
{
global.log(EXTENSION_NAME + " - Trying lock using xscreensaver-command");
Util.spawn(['xscreensaver-command', '--lock']) // do the actual lock
}


// v2: using gnome-screensaver-command --lock
//
var checkExistanceOfGnomeScreensaverCommand=GLib.find_program_in_path('gnome-screensaver-command')
if(checkExistanceOfGnomeScreensaverCommand == null)
{
global.log(EXTENSION_NAME + " - gnome-screensaver-command not in path or not found");
}
else
{
global.log(EXTENSION_NAME + " - Trying lock using gnome-screensaver-command");
Util.spawn(['gnome-screensaver-command', '--lock']) // do the actual lock
}

global.log(EXTENSION_NAME + " - Finished _lock()");
},


// ########################################################################
// Preferences - Not in use so far - should open a preference dialog
//
// ########################################################################
_onPreferences: function() {
global.log(EXTENSION_NAME + " - Starting _onPreferences()");
Util.spawn(['notify-send', 'Lock my desktop', 'On Preferences - Dummy']) // show notification
global.log(EXTENSION_NAME + " - Finished _onPreferences()");
},


// ########################################################################
// About - Opens the project Github page
//
// ########################################################################
_onAbout: function() {
global.log(EXTENSION_NAME + " - Starting _onAbout()"); // log
Util.spawn(['xdg-open', EXTENSION_URL]) // open project url
global.log(EXTENSION_NAME + " - Finished _onAbout()"); // log
}

});



// ############################################################################
//
// ############################################################################
function init(extensionMeta) {
imports.gettext.bindtextdomain("gnome-shell-extension-lock-my-desktop", extensionMeta.path + "/locale");
//imports.gettext.bindtextdomain("gnome-shell-extension-lock-my-desktop", extensionMeta.path + "/locale");
imports.gettext.bindtextdomain("lock-my-desktop", extensionMeta.path + "/locale");
}

let _indicator;



// ############################################################################
// Enable the extension
//
// ############################################################################
function enable() {
_indicator = new MainMenu;
Main.panel.addToStatusArea('lockMyDesktopMain_button', _indicator);

global.log(EXTENSION_NAME +" enabled");
global.log(EXTENSION_NAME +" - Extension enabled"); // log
}



// ############################################################################
// Disable the extension
//
// ############################################################################
function disable() {
_indicator.destroy();

global.log(EXTENSION_NAME + " disabled");
global.log(EXTENSION_NAME + " - Extension disabled"); // log
}

10 changes: 3 additions & 7 deletions lock-my-desktop@yafp.de/metadata.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"name": "Lock my desktop",
"description": "Adds a menu with lock functionality to the Gnome panel",
"description": "Adds a menu with lock functionality to the gnome-shell panel",
"uuid": "lock-my-desktop@yafp.de",
"url": "http://github.com/yafp/gnome-shell-extension-lock-my-desktop",
"shell-version": [
"3.18",
"3.22",
"3.24"
],
"version": 1
"shell-version": ["3.18", "3.22", "3.24"],
"version": 0.1
}

0 comments on commit 68ec01d

Please sign in to comment.