Skip to content

Commit

Permalink
Included same feature as master e729d4e but for shell version from 2.…
Browse files Browse the repository at this point in the history
…8 to 3.5
  • Loading branch information
Tommimon committed Jun 24, 2020
1 parent e688f17 commit 0823b5d
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 226 deletions.
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Add to Desktop
An easy way to create desktop app shortcut in gnome
An easy way to create desktop app shortcut in GNOME

## Overview
This simple extension tries to make easier the gnome process to create a desktop
This simple extension tries to make easier the GNOME process to create a desktop
shortcut for apps.

The idea is simple: instead of searching for the .desktop files throw multiple
folders let's use the gnome application launcher that already groups all our apps.
The idea is simple: instead of searching for the `.desktop` files through multiple
folders let's use the application launcher that already groups all our apps.

This extension adds a new line to the app context menu in the application launcher,
the new entry ('Add to Desktop') if clicked automatically creates a desktop shortcut
Expand All @@ -16,16 +16,19 @@ When you have your shortcut on the desktop you still have to enable it with
right-click and 'Allow Launching' as if you create the shortcut manually.

## Dependencies
This extension needs the [desktop-icons](https://extensions.gnome.org/extension/1465/desktop-icons/)
This extension needs the [Desktop Icons](https://extensions.gnome.org/extension/1465/desktop-icons/)
extension installed and enabled to work properly.
Otherwise you will not be able to see the shortcuts you are creating.

Currently, I'm working to get this extension merged in Desktop Icons project, if you would like
having this feature by default in Desktop Icons extension let them now.

## Installation
- Download zip from the releases section or gnome-shell extensions site
- Extract in a folder called `add-to-desktop@tommimon.github.com`
- Add the `add-to-desktop@tommimon.github.com` folder to gnome extensions folder*
- Restart the Gnome-Shell**
- Open (or restart) the Extensions app
- Download zip from the releases section
- Extract in a folder named `add-to-desktop@tommimon.github.com`
- Add the `add-to-desktop@tommimon.github.com` folder to GNOME extensions folder*
- Restart the GNOME shell**
- Open (or restart) the Extensions app (or Tweaks app)
- Enable 'Add to Desktop'
- Enjoy

Expand All @@ -43,12 +46,12 @@ can get to the windows concept of shortcut.
Many people copy the .desktop file to the desktop instead of creating a soft link.
I encourage using links because this fixes many issues with application updates:
if your application gets updated the behaviour of the `.desktop` file may change, I
experienced app icons changing path upgrading, this may make your shortcut no more
experienced app icons changing path updating, this may make your shortcut no more
working properly, and you have to create a new one from zero. With soft links this shouldn't
happen as long as the `.desktop` file used by the application launcher stay in the
happen as long as the `.desktop` file used by the application launcher remains in the
same place which usually is the case.

This approach has a dow side: permission issues but now this extension takes care automatically
This approach has a downside: permission issues but now this extension takes care automatically
of those problems and changes the launcher file permissions adding the executable
permission if and only when needed. This operation may require root authentication
permission if and only if is needed. This operation may require root authentication
if the file is owned by another user.
38 changes: 0 additions & 38 deletions asyncExec.js

This file was deleted.

52 changes: 0 additions & 52 deletions checkPermissions.js

This file was deleted.

42 changes: 7 additions & 35 deletions extension.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,22 @@
const AppDisplay = imports.ui.appDisplay;
const GLib = imports.gi.GLib;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const PermissionsHandler = Me.imports.permissionsHandler;
const MyLog = Me.imports.myLog.MyLog;
const ShortcutMaker = Me.imports.shortcutMaker;

// var because accessed elsewhere
var DESKTOP_DIRECTORY = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP);

// Save the standard Menu globally to be able to reset it
var ParentMenu;
// Saves the standard Menu globally to be able to reset it on disable
var parentMenu = null;

function init () {
ParentMenu = AppDisplay.AppIconMenu;
MyLog("init completed");
}

function insertCustomEntry(menu) {
// Add the "Add to Desktop" entry to the menu
menu._appendSeparator();
let item = menu._appendMenuItem("Add to Desktop");
item.connect('activate', () => {
let appPath = menu._source.app.get_app_info().get_filename(); // get the .desktop file complete path
MyLog(appPath);
let handler = new PermissionsHandler.PermissionsHandler(appPath);
handler.start();
});
}

function enable () {
// AppIconMenu is the var which contains the class used to instantiate the context menu
// Assigning my own custom menu that extends the standard menu so the custom will be used for instantiate
AppDisplay.AppIconMenu = class customMenu extends ParentMenu {
_redisplay() {
super._redisplay();
insertCustomEntry(this);
}
}

MyLog("DESKTOP_DIRECTORY = " + DESKTOP_DIRECTORY);
MyLog("enable completed");
parentMenu = AppDisplay.AppIconMenu;
ShortcutMaker.addShortcutButton(parentMenu);
}

function disable () {
// Reset the menu to the standard one (not customized)
AppDisplay.AppIconMenu = ParentMenu;
MyLog("disable completed");
// Reset the menu to the standard one (without new item)
AppDisplay.AppIconMenu = parentMenu;
}
3 changes: 0 additions & 3 deletions myLog.js

This file was deleted.

84 changes: 0 additions & 84 deletions permissionsHandler.js

This file was deleted.

Loading

0 comments on commit 0823b5d

Please sign in to comment.