Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin .desktop syntax #250

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ regex = "1.11.0"
ron = "0.8.1"
tokio = "1.40.0"
tokio-stream = "0.1.16"
freedesktop-desktop-entry = "0.7.5"

[dependencies]
const_format = "0.2.33"
@@ -50,8 +51,9 @@ workspace = true
features = ["io-util"]


# [patch.crates-io]
[patch.crates-io]
# freedesktop-desktop-entry = { path = "../freedesktop-desktop-entry" }
freedesktop-desktop-entry = { git = "https://github.com/wiiznokes/freedesktop-desktop-entry", branch = "update" }

[patch."https://github.com/pop-os/cosmic-protocols"]
"cosmic-client-toolkit" = { git = "https://github.com/pop-os//cosmic-protocols" }
135 changes: 109 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -49,31 +49,112 @@ just plugins="calc desktop_entries files find pop_shell pulse recent scripts ter

## Plugin Config

A plugin's metadata is defined `pop-launcher/plugins/{plugin}/plugin.ron`.

```ron
(
name: "PluginName",
description: "Plugin Description: Example",
bin: (
path: "name-of-executable-in-plugin-folder",
),
icon: Name("icon-name-or-path"),
// Optional
query: (
// Optional -- if we should isolate this plugin when the regex matches
isolate: true,
// Optional -- Plugin which searches on empty queries
persistent: true,
// Optional -- avoid sorting results from this plugin
no_sort: true,
// Optional -- pattern that a query must have to be sent to plugin
regex: "pattern",
// Optional -- the launcher should keep a history for this plugin
history: true,
)
)
```
A plugin's manifest file should be installed in `{plugin_directory}`. The syntax respect the [freedesktop specification](https://specifications.freedesktop.org/desktop-entry-spec/latest/index.html). An example can be found [here](./plugins/src/calc/plugin.desktop).

This are the supported fields. The ones with no default are required.

<table>
<tr>
<th>Field</th>
<th>Description</th>
<th>Type</th>
<th>Default</th>
<th>Translatable</th>
</tr>
<tr>
<td>Name</td>
<td>Plugin desciption</td>
<td>localestring</td>
<td></td>
<td>yes</td>
</tr>
<tr>
<td>Description</td>
<td>Plugin name</td>
<td>localestring</td>
<td>empty string</td>
<td>yes</td>
</tr>
<tr>
<td>Icon</td>
<td>Icon name, respecting the [icon theme spec](https://freedesktop.org/wiki/Specifications/icon-theme-spec/).</td>
<td>iconstring</td>
<td>no icon</td>
<td>no</td>
</tr>
<tr>
<td>Exec</td>
<td>Executable file. Should either an absolute path, or a path relative to {plugin_directory}</td>
<td>string</td>
<td></td>
<td>no</td>
</tr>
<tr>
<td>Regex</td>
<td>Activate the plugin when this regex match the query</td>
<td>regex</td>
<td>match all query</td>
<td>no</td>
</tr>
<tr>
<td>Isolate</td>
<td>Isolate this plugin when the regex field matches</td>
<td>boolean</td>
<td>false</td>
<td>no</td>
</tr>
<tr>
<td>IsolateWith</td>
<td>Isolate this plugin when this regex matches</td>
<td>regex</td>
<td>match nothing</td>
<td>no</td>
</tr>
<tr>
<td>ShowOnEmptyQuery</td>
<td>Show plugin's result on empty queries</td>
<td>boolean</td>
<td>false</td>
<td>no</td>
</tr>
<tr>
<td>NoSort</td>
<td>Avoid sorting results from this plugin</td>
<td>boolean</td>
<td>false</td>
<td>no</td>
</tr>
<tr>
<td>GenericQuery</td>
<td>Default query that will activate this plugin</td>
<td>localestring</td>
<td>empty string</td>
<td>no</td>
</tr>
<tr>
<td>LongLived</td>
<td>The plugin should always run in the background</td>
<td>boolean</td>
<td>false</td>
<td>no</td>
</tr>
<tr>
<td>History</td>
<td>The launcher should keep a history for this plugin</td>
<td>boolean</td>
<td>false</td>
<td>no</td>
</tr>
<tr>
<td>Priority</td>
<td>Result priority of the plugin</td>
<td>Default, High or Low</td>
<td>Default</td>
<td>no</td>
</tr>
</table>



## Script Directories

@@ -82,6 +163,7 @@ A plugin's metadata is defined `pop-launcher/plugins/{plugin}/plugin.ron`.
- Distribution packaging: `/usr/lib/pop-launcher/scripts`

Example script

<details>
<pre>
#!/bin/sh
@@ -92,6 +174,7 @@ Example script
# keywords: vpn start connect

nmcli connection up "vpn-name"

</pre>
</details>

@@ -231,7 +314,7 @@ Where `PluginSearchResult` is:
`GpuPreference` is:

```ts
"Default" | "NonDefault"
"Default" | "NonDefault";
```

And `IconSource` is either:
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ install-plugins:
for plugin in {{plugins}}; do
dest={{plugin-dir}}${plugin}
mkdir -p ${dest}
install -Dm0644 plugins/src/${plugin}/*.ron ${dest}
install -Dm0644 plugins/src/${plugin}/*.desktop ${dest}
ln -srf {{bin-path}} {{plugin-dir}}${plugin}/$(echo ${plugin} | sed 's/_/-/')
done

2 changes: 1 addition & 1 deletion plugins/Cargo.toml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ publish = false
[dependencies]
async-pidfd = "0.1.4"
fork = "0.2.0"
freedesktop-desktop-entry = "0.6.2"
freedesktop-desktop-entry.workspace = true
human_format = "1.1.0"
human-sort = "0.2.2"
new_mime_guess = "4.0.4"
10 changes: 10 additions & 0 deletions plugins/src/calc/plugin.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Plugin]
Name=Calculator with unit conversion (uses Qalculate! expressions)
Name[fr]=Calculatrice avec conversion d'unités (utilise les Qalculate! expressions)
Description=Syntax: = <expression>\nExample: = 10 J / (196x^2) = 4 kW/s
Exec=calc
Icon=x-office-spreadsheet
Regex=^[=\\-0-9|(-0-9)].*
GenericQuery==\s
Priority=High
IsolateWith="^(=).*"
13 changes: 0 additions & 13 deletions plugins/src/calc/plugin.ron

This file was deleted.

Loading