-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Aylur/feat/greetd
feat: greetd ipc client
- Loading branch information
Showing
12 changed files
with
569 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Greet | ||
|
||
Library and CLI tool for sending requests to [greetd](https://sr.ht/~kennylevinsen/greetd/). | ||
|
||
## Installation | ||
|
||
1. install dependencies | ||
|
||
:::code-group | ||
|
||
```sh [<i class="devicon-archlinux-plain"></i> Arch] | ||
sudo pacman -Syu meson vala json-glib gobject-introspection | ||
``` | ||
|
||
```sh [<i class="devicon-fedora-plain"></i> Fedora] | ||
sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel | ||
``` | ||
|
||
```sh [<i class="devicon-ubuntu-plain"></i> Ubuntu] | ||
sudo apt install meson valac libjson-glib-dev gobject-introspection | ||
``` | ||
|
||
::: | ||
|
||
::: info | ||
Although `greetd` is not a direct build dependency, | ||
it should be self-explanatory that the daemon is required to be available at runtime. | ||
::: | ||
|
||
2. clone repo | ||
|
||
```sh | ||
git clone https://github.com/aylur/astal.git | ||
cd astal/lib/greet | ||
``` | ||
|
||
3. install | ||
|
||
```sh | ||
meson setup --prefix /usr build | ||
meson install -C build | ||
``` | ||
|
||
## Usage | ||
|
||
You can browse the [Greet reference](https://aylur.github.io/libastal/greet). | ||
|
||
### CLI | ||
|
||
```sh | ||
astal-greet --help | ||
``` | ||
|
||
### Library | ||
|
||
:::code-group | ||
|
||
```js [<i class="devicon-javascript-plain"></i> JavaScript] | ||
import Greet from "gi://AstalGreet" | ||
|
||
Greet.login("username", "password", "compositor", (_, res) => { | ||
try { | ||
Greet.login_finish(res) | ||
} catch (err) { | ||
printerr(err) | ||
} | ||
}) | ||
``` | ||
|
||
```py [<i class="devicon-python-plain"></i> Python] | ||
# Not yet documented | ||
|
||
``` | ||
|
||
```lua [<i class="devicon-lua-plain"></i> Lua] | ||
local Greet = require("lgi").require("AstalGreet") | ||
|
||
Greet.login("username", "password", "compositor", function (_, res) | ||
local err = Greet.login_finish(res) | ||
if err ~= nil then | ||
print(err) | ||
end | ||
end) | ||
``` | ||
|
||
```vala [<i class="devicon-vala-plain"></i> Vala] | ||
try { | ||
yield AstalGreet.login("username", "password", "compositor"); | ||
} catch (Error err) { | ||
printerr(err.message); | ||
} | ||
``` | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
static bool help; | ||
static bool version; | ||
static string username; | ||
static string password; | ||
static string cmd; | ||
[CCode (array_length = false, array_null_terminated = true)] | ||
static string[] env; | ||
|
||
const OptionEntry[] options = { | ||
{ "version", 'v', OptionFlags.NONE, OptionArg.NONE, ref version, null, null }, | ||
{ "help", 'h', OptionFlags.NONE, OptionArg.NONE, ref help, null, null }, | ||
{ "username", 'u', OptionFlags.NONE, OptionArg.STRING, ref username, null, null }, | ||
{ "password", 'p', OptionFlags.NONE, OptionArg.STRING, ref password, null, null }, | ||
{ "cmd", 'c', OptionFlags.NONE, OptionArg.STRING, ref cmd, null, null }, | ||
{ "env", 'e', OptionFlags.NONE, OptionArg.STRING_ARRAY, ref env, null, null }, | ||
{ null }, | ||
}; | ||
|
||
async int main(string[] argv) { | ||
try { | ||
var opts = new OptionContext(); | ||
opts.add_main_entries(options, null); | ||
opts.set_help_enabled(false); | ||
opts.set_ignore_unknown_options(false); | ||
opts.parse(ref argv); | ||
} catch (OptionError err) { | ||
printerr (err.message); | ||
return 1; | ||
} | ||
|
||
if (help) { | ||
print("Usage:\n"); | ||
print(" %s [flags]\n\n", argv[0]); | ||
print("Flags:\n"); | ||
print(" -h, --help Print this help and exit\n"); | ||
print(" -v, --version Print version number and exit\n"); | ||
print(" -u, --username User to login to\n"); | ||
print(" -p, --password Password of the user\n"); | ||
print(" -c, --cmd Command to start the session with\n"); | ||
print(" -e, --env Additional env vars to set for the session\n"); | ||
return 0; | ||
} | ||
|
||
if (version) { | ||
printerr(AstalGreet.VERSION); | ||
return 0; | ||
} | ||
|
||
if (username == null) { | ||
printerr("missing username\n"); | ||
return 1; | ||
} | ||
|
||
if (password == null) { | ||
printerr("missing password\n"); | ||
return 1; | ||
} | ||
|
||
if (cmd == null) { | ||
printerr("missing cmd\n"); | ||
return 1; | ||
} | ||
|
||
try { | ||
yield AstalGreet.login_with_env(username, password, cmd, env); | ||
} catch (Error err) { | ||
printerr(err.message); | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.