diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/DBUS.md | 20 | ||||
-rw-r--r-- | docs/INTERNAL_SERVER.md | 28 | ||||
-rw-r--r-- | docs/MIGRATION.md | 38 | ||||
-rw-r--r-- | docs/dbus/ferdium_bar.py | 102 | ||||
-rw-r--r-- | docs/dbus/org.ferdium.Ferdium.xml | 80 | ||||
-rw-r--r-- | docs/dbus/requirements.txt | 1 |
6 files changed, 269 insertions, 0 deletions
diff --git a/docs/DBUS.md b/docs/DBUS.md new file mode 100644 index 000000000..ffbd61f4b --- /dev/null +++ b/docs/DBUS.md | |||
@@ -0,0 +1,20 @@ | |||
1 | # D-Bus interface | ||
2 | |||
3 | Ferdium exposes an inter-process communication on Linux systems via [D-Bus](https://www.freedesktop.org/wiki/Software/dbus/). | ||
4 | This allows integrating Ferdium with your desktop environment by displaying the number of unread notifications in a status area and muting or unmuting notations. | ||
5 | |||
6 | ## Desktop integration | ||
7 | |||
8 | As an example integration, the [`docs/dbus`](dbus) folder contains a module for status bars written in Python. | ||
9 | To run the example, you'll need Python 3.11 and the [`dbus-next`](https://pypi.org/project/dbus-next/) PyPI package. | ||
10 | |||
11 | The integration uses the [`FerdiumClient`](dbus/ferdium_client.py) client library, which is an asynchronous wrapper over the D-Bus interface. | ||
12 | It illustrates multiple advanced concepts, such as asynchronous communication with Ferdium via `asyncio` and polling the session D-Bus to see if Ferdium is running. | ||
13 | |||
14 | The [`ferdium_bar.py`](dbus/ferdium_bar.py) implements a bar module to use with status bars such as waybar or polybar. See `ferdium_bar.py --help` and `ferdium_bar.py unread --help` for further indications on how to use it. | ||
15 | |||
16 | ## Low-level API | ||
17 | |||
18 | The low-level API exposed over D-Bus is documented in [`org.ferdium.Ferdium.xml](docs/org.ferdium.Ferdium.xml) with standard D-Bus introspection syntax. | ||
19 | |||
20 | Ferdium will take ownership of the bus name `org.ferdium.Ferdium` and expose and object implementing the `org.ferdium.Ferdium` interface at the object path `/org/ferdium`. | ||
diff --git a/docs/INTERNAL_SERVER.md b/docs/INTERNAL_SERVER.md new file mode 100644 index 000000000..9e94f9bdf --- /dev/null +++ b/docs/INTERNAL_SERVER.md | |||
@@ -0,0 +1,28 @@ | |||
1 | <p align="center"> | ||
2 | <img src="../src/internal-server/public/images/logo.png" alt="" width="300"/> | ||
3 | </p> | ||
4 | |||
5 | # ferdium-internal-server | ||
6 | Internal Ferdium Server used for storing settings/preferences without logging into an external server. | ||
7 | |||
8 | ## Differences to ferdium-server | ||
9 | - Doesn't contain user management (only one user) | ||
10 | - Doesn't require logging in | ||
11 | - No recipe creation | ||
12 | - Contains `start.js` script to allow starting the server via script | ||
13 | - Uses `env.ini` instead of `.env` to stay compatible with Ferdium's build script | ||
14 | - Only allows Ferdium clients to connect to the API | ||
15 | |||
16 | ## Configuration | ||
17 | `ferdium-internal-server's` configuration is saved inside the `env.ini` file. Besides AdonisJS's settings, `ferdium-internal-server` has the following custom settings: | ||
18 | - `CONNECT_WITH_FRANZ` (`true` or `false`, default: `true`): Whether to enable connections to the Franz server. By enabling this option, `ferdium-internal-server` can: | ||
19 | - Show the full Franz/Ferdi recipe library instead of only custom recipes | ||
20 | - Import Franz/Ferdi accounts | ||
21 | |||
22 | ## Exporting backups | ||
23 | Since the `ferdium-internal-server` runs a local server, there's no automatic syncing of settings possible. You can backup your settings, by clicking on `Help > Import/Export Configuration Data` which will open the running server page in your browser. Choose the option to export and save the generated file. | ||
24 | |||
25 | ## Importing your Franz/Ferdi account | ||
26 | `ferdium-internal-server` allows you to import your full Franz account, including all its settings. | ||
27 | |||
28 | To import your Franz/Ferdi account, within Ferdium, click on `Help > Import/Export Configuration Data` which will open the running server page in your browser. You can then login using your Franz account details. `ferdium-internal-server` will create a new user with the same credentials and copy your Franz settings, services and workspaces. | ||
diff --git a/docs/MIGRATION.md b/docs/MIGRATION.md new file mode 100644 index 000000000..bb1ca315d --- /dev/null +++ b/docs/MIGRATION.md | |||
@@ -0,0 +1,38 @@ | |||
1 | # Migrating account data | ||
2 | |||
3 | This guide is here to show you how to export your current Ferdi setup from the online server or from an accountless session for safe-keeping, backup or transferring to a new instance using only a browser. | ||
4 | |||
5 | Before getting into the details of using an online account vs accountless, let's quickly review what the differences are between the two of them: | ||
6 | |||
7 | ## Using Ferdi with an Account | ||
8 | |||
9 | The main advantage of using Ferdi with an account is that you have your configuration data stored on a cloud - and thus, when moving to a different machine, once you login, all these configurations are applied to the Ferdi instance on your new machine. | ||
10 | |||
11 | **But**, if you use a Ferdi account, you need to reach their servers. If the servers are not accessible, you sadly have no other options for getting your data as there are no local copies. So it is advised to do this as soon as there's a chance - just to be safe. | ||
12 | |||
13 | ## Using Ferdi without an account i.e. Accountless | ||
14 | |||
15 | Accountless instances have all the same functionality as account-based ones with the exception of multi-machine syncronization. If you don't intend to use this app on multiple machines with regularly changing settings and lists of services, there's no benefit to having an online account. Having a backup of your `export.ferdi-data` whenever you make changes to your setup, provides a similarly secure (albeit slower and manual alternative) to automatic syncing that doesn't rely on a server's constant availability. | ||
16 | |||
17 | ## Exporting | ||
18 | |||
19 | Depending on where you have your account, you have to visit separate sites to retrieve it. This has no impact on your current instances. You can follow the next steps to access and export that data irrespective of which online server holds your data. | ||
20 | |||
21 | 1. Have Ferdi running on your system. (Even if you are on the initial "Get started" page, these instructions will work.) | ||
22 | 2. Go to `Help > Import/Export Configuration Data` which should open the corresponding url in your default browser. | ||
23 | 3. Click on `export your data to a ".ferdi-data" file`. | ||
24 | 4. Save the `export.ferdi-data` file to anywhere you'd like for safe-keeping/backup. | ||
25 | |||
26 | ## Importing | ||
27 | |||
28 | 1. Have Ferdium running on your system. | ||
29 | 2. When you get to the screen that says "Get Started", go to `Help > Import/Export Configuration Data` which should open a local url in your default browser. | ||
30 | 3. Click on `import your data from a ".ferdium-data" or ".ferdi-data" file`. | ||
31 | 4. Using the File browser button, find the previously saved `export.ferdi-data` file on your system and click the "Import data" button. | ||
32 | 5. Restart your application. | ||
33 | |||
34 | _Note:_ | ||
35 | |||
36 | 1. Setting up new instances or migrating to an accountless setup will require all services to be logged-in by hand again. This is because the session information only stays on your local machine - ever. | ||
37 | 2. Importing data does not override the list of local services if you have any, but adds them to the current list. This is normal behavior. If you do not want to deal with duplicate instances of services, you can delete your pre-existing services prior to importing from the previously exported data file. | ||
38 | 3. Due to current risks of losing access to Ferdi's services, it is ill-advised to use their servers in the future. You should setup your own server while you wait for official Ferdium solutions (if automatic syncing is important to you). | ||
diff --git a/docs/dbus/ferdium_bar.py b/docs/dbus/ferdium_bar.py new file mode 100644 index 000000000..6fd5d8c30 --- /dev/null +++ b/docs/dbus/ferdium_bar.py | |||
@@ -0,0 +1,102 @@ | |||
1 | import asyncio | ||
2 | import argparse | ||
3 | import html | ||
4 | |||
5 | from ferdium_dbus import Client | ||
6 | |||
7 | |||
8 | async def toggle_window(client, args): | ||
9 | """Toggle window visibility""" | ||
10 | |||
11 | await client.toggle_window() | ||
12 | |||
13 | |||
14 | async def toggle_mute(client, args): | ||
15 | """Toggle mute status""" | ||
16 | |||
17 | await client.toggle_mute() | ||
18 | |||
19 | |||
20 | async def unread(client, args): | ||
21 | """Get unread messages count""" | ||
22 | |||
23 | def callback(): | ||
24 | """Print unread count(s)""" | ||
25 | |||
26 | # For each service | ||
27 | counts = {} | ||
28 | for service in client.unread_services: | ||
29 | name, direct, indirect = service | ||
30 | safe_name = html.escape(name) | ||
31 | |||
32 | # If it's exactly the service we're looking for, just return the count | ||
33 | if safe_name == args.services: | ||
34 | count = direct | ||
35 | if not args.direct: | ||
36 | count += indirect | ||
37 | print(count) | ||
38 | return | ||
39 | |||
40 | # If the service in included in the services we're looking for | ||
41 | if args.services in ("total", "all") or safe_name in args.services: | ||
42 | counts[safe_name] = direct | ||
43 | if not args.direct: | ||
44 | counts[safe_name] += indirect | ||
45 | |||
46 | # Get total notifications | ||
47 | if args.services == "total": | ||
48 | print(sum(counts.values())) | ||
49 | return | ||
50 | |||
51 | # Finally, print each service notifications on a different line | ||
52 | print( | ||
53 | "\n".join( | ||
54 | f"{name}: {count}" | ||
55 | for name, count in counts.items() | ||
56 | ) | ||
57 | ) | ||
58 | |||
59 | # Do print counts and keep running if tail mode enabled | ||
60 | callback() | ||
61 | if args.tail: | ||
62 | client.on_change(callback) | ||
63 | await asyncio.get_running_loop().create_future() | ||
64 | |||
65 | |||
66 | async def main(): | ||
67 | """Main cli interface""" | ||
68 | |||
69 | # Define commands | ||
70 | commands = { | ||
71 | "unread": unread, | ||
72 | "toggle-mute": toggle_mute, | ||
73 | "toggle-window": toggle_window, | ||
74 | } | ||
75 | |||
76 | # Arguments parser | ||
77 | argparser = argparse.ArgumentParser(description="Script to interact with Ferdium on your bar") | ||
78 | subparsers = argparser.add_subparsers(dest="command", required=True) | ||
79 | # Unread command | ||
80 | argparser_unread = subparsers.add_parser("unread", help=unread.__doc__) | ||
81 | argparser_unread.add_argument("-s", "--services", default="total", help="Which services to get notifications from {total, all, <name>} (the name can be a comma-separated list)") | ||
82 | argparser_unread.add_argument("-d", "--direct", action="store_true", default=False, help="Get only direct (mentions or DM) messages") | ||
83 | argparser_unread.add_argument("-t", "--tail", action="store_true", default=False, help="Keep running and print on change") | ||
84 | # Toggle mute and toggle window commands | ||
85 | argparser_toggle_mute = subparsers.add_parser("toggle-mute", help=toggle_mute.__doc__) | ||
86 | argparser_toggle_window = subparsers.add_parser("toggle-window", help=toggle_window.__doc__) | ||
87 | # Get args | ||
88 | args = argparser.parse_args() | ||
89 | |||
90 | # Initialise ferdium client | ||
91 | client = Client() | ||
92 | await client.connect() | ||
93 | if not client.running: | ||
94 | print("not running") | ||
95 | return | ||
96 | |||
97 | # Execute command | ||
98 | await commands[args.command](client, args) | ||
99 | |||
100 | |||
101 | if __name__ == "__main__": | ||
102 | asyncio.run(main()) | ||
diff --git a/docs/dbus/org.ferdium.Ferdium.xml b/docs/dbus/org.ferdium.Ferdium.xml new file mode 100644 index 000000000..8c66a9e21 --- /dev/null +++ b/docs/dbus/org.ferdium.Ferdium.xml | |||
@@ -0,0 +1,80 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" | ||
3 | "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> | ||
4 | <node> | ||
5 | <!-- | ||
6 | org.ferdium.Ferdium: | ||
7 | @short_description: Control Ferdium from the desktop | ||
8 | |||
9 | Interface for accessing Ferdium notification state, allowing notification | ||
10 | counts to be displayed in the desktop (e.g., on a status bar) and updating | ||
11 | the muted state of notifications. | ||
12 | |||
13 | The #org.ferdium.UnreadDirectMessageCount, | ||
14 | #org.ferdium.UnreadIndirectMessageCount, and #org.ferdium.UnreadServices | ||
15 | are affected by notification muting and hiding settings of Ferdium. | ||
16 | In particular, they are not updated if #org.ferdium.Muted is #TRUE. | ||
17 | Moreover, services with muted notifications or hidden indirect message | ||
18 | counts will not appear in the respective counts. | ||
19 | This behavior is consistent with the behavior of the Ferdium tray icon. | ||
20 | --> | ||
21 | <interface name="org.ferdium.Ferdium"> | ||
22 | <!-- | ||
23 | ToggleMute: | ||
24 | |||
25 | Toggles the muted state of notifcations. | ||
26 | |||
27 | Use the #org.ferdium.Ferdium.Muted property to get or set the current | ||
28 | muted state. | ||
29 | --> | ||
30 | <method name="ToggleMute" /> | ||
31 | <!-- | ||
32 | ToggleWindow: | ||
33 | |||
34 | Brings the Ferdium window into the foreground if it is not currently | ||
35 | focused. Hides the Ferdium window if is is currently focused. | ||
36 | |||
37 | Calling this method is equivalent to clicking on the Ferdium tray icon. | ||
38 | --> | ||
39 | <method name="ToggleWindow" /> | ||
40 | <!-- | ||
41 | Muted: | ||
42 | |||
43 | Gets or sets the current muted state of notifications. | ||
44 | |||
45 | #TRUE if notifications are currently muted, #FALSE otherwise. | ||
46 | --> | ||
47 | <property name="Muted" type="b" access="readwrite" /> | ||
48 | <!-- | ||
49 | UnreadDirectMessageCount: | ||
50 | |||
51 | The number of unread direct messages. | ||
52 | --> | ||
53 | <property name="UnreadDirectMessageCount" type="u" access="read" /> | ||
54 | <!-- | ||
55 | UnreadIndirectMessageCount: | ||
56 | |||
57 | The number of unread indirect messages. | ||
58 | --> | ||
59 | <property name="UnreadIndirectMessageCount" type="u" access="read" /> | ||
60 | <!-- | ||
61 | UnreadServices: | ||
62 | |||
63 | The list of services with unread messages. | ||
64 | |||
65 | The value of this property is an array of structs corresponding to each | ||
66 | service with unread messages. | ||
67 | The elements of a struct are the following: | ||
68 | |||
69 | 1. The name of the service. | ||
70 | |||
71 | 2. The number of unread direct messages of the service. | ||
72 | |||
73 | 3. The number of unread indirect messages of the service. | ||
74 | |||
75 | Services with no unread direct or indirect messages (i.e., structs with | ||
76 | the second and third element set to 0) are omitted from the array. | ||
77 | --> | ||
78 | <property name="UnreadServices" type="a(suu)" access="read" /> | ||
79 | </interface> | ||
80 | </node> | ||
diff --git a/docs/dbus/requirements.txt b/docs/dbus/requirements.txt new file mode 100644 index 000000000..d08a849d9 --- /dev/null +++ b/docs/dbus/requirements.txt | |||
@@ -0,0 +1 @@ | |||
git+https://github.com/victorbnl/ferdium-dbus-py | |||