Disabling/Deleting desktop file components in KGlobalAccel
Open, Needs TriagePublic

Description

KGlobalAccel can consume desktop file in order to set shortcuts for launching applications/invoking actions. To do so they must be in GenericDataLocation/kglobalaccel which typically is /usr/share/kglobalaccel or ~/.local/share/kglobalaccel. When such a component is disabled the current idea is that we write NoDisplay=true to the desktop file to mark it as disabled.
This has multiple shortcomings

  1. It doesn't work for desktop files that are not writable
  2. It abuses a well defined attribute and modifies .desktop files. Some applications link rather than copy their desktop files to the kglobalaccel directories. If we write the no display attribute to such a file we make the Application invisible.
  3. I couldn't find a place where the NoDisplay attribute is potentially removed if a file is readded again.

A solution could be

  1. Copy the file to writeable location if it is not writeable. This is straightforward.
  2. Use a custom attribute to store that a component is disabled. See D25088
  3. Remove the custom attribute when a component is added again. I think the constructor of KServiceActionComponent would a good place for that.

Alternatively we could store the disabled components in the configuration file (kglobalshortcutsrc) D28856. This avoids the issues entirely because we no longer need to mutate the desktop files. This is what I would also prefer for the future way forward for kglobalaccel.

Migration is potentially difficult because of the issues mentioned above. But it could have worked for files that were imported by the user and removed again. Can we just ignore it? Or do you have good ideas?

davidre created this task.Apr 16 2020, 8:25 AM
davidre updated the task description. (Show Details)

I would like to have an action plan as I'm currently doing D28744 and would like to have something working for it. That would mean something in KF 5.70 timeframe. For now we could also only do 1. and 3. and continue using NoDisplay.

davidre updated the task description. (Show Details)Apr 16 2020, 8:35 AM

<fvogt> Migration should be relatively straightforward: Iterate all .desktop files and components with NoDisplay to the setting
<fvogt> Removing NoDisplay wouldn't be necessary as it would be ignored by kglobalaccel anyway

davidre updated the task description. (Show Details)Apr 16 2020, 8:38 AM

Copy the file to writeable location if it is not writeable. This is straightforward.

The local version is just for masking, it doesn't need to be a copy. It just wants to write out.

foo.desktop:

[Desktop Entry] 
Hidden=true

Then we delete the file when we unmask - that way we don't have any keeping in sync problems.

To me it seems easier, and how I imagined it worked when the initial thing landed.


But I'm fine with approach 2 too.
In your fix for 2, why do you make a new entry disabledComponents instead of writing a tag into the relevant [componentName] section

Copy the file to writeable location if it is not writeable. This is straightforward.

The local version is just for masking, it doesn't need to be a copy. It just wants to write out.

foo.desktop:

[Desktop Entry] 
 Hidden=true

So you would just create a dummy file if it doesn't exist yet? I don't see how that makes stuff easier?

Then we delete the file when we unmask - that way we don't have any keeping in sync problems.

To me it seems easier, and how I imagined it worked when the initial thing landed.


But I'm fine with approach 2 too.
In your fix for 2, why do you make a new entry disabledComponents instead of writing a tag into the relevant [componentName] section

Because I didn't think of it :)

Copy the file to writeable location if it is not writeable. This is straightforward.

The local version is just for masking, it doesn't need to be a copy. It just wants to write out.

foo.desktop:

[Desktop Entry] 
 Hidden=true

So you would just create a dummy file if it doesn't exist yet? I don't see how that makes stuff easier?

Then we delete the file when we unmask - that way we don't have any keeping in sync problems.

To me it seems easier, and how I imagined it worked when the initial thing landed.

Nevermind I think I understand :

  1. Delete desktop file in cleanup (if it works all is fine) if not is systemfile and whatever
  2. Create dummy file with hidden= true
  3. When component is added the thing that wants stuff overwote the dummy file?