feat: add ipc commands for stuff
This commit is contained in:
parent
c1d1bf447b
commit
c214b3c5d6
5 changed files with 110 additions and 4 deletions
27
README.md
27
README.md
|
|
@ -35,9 +35,32 @@ For a preconfigured setup, install [`caelestia-hypr`](https://github.com/caelest
|
||||||
[this file](https://github.com/caelestia-dots/hypr/blob/main/hyprland/keybinds.conf#L1-L29) for an example on how to use global
|
[this file](https://github.com/caelestia-dots/hypr/blob/main/hyprland/keybinds.conf#L1-L29) for an example on how to use global
|
||||||
shortcuts.
|
shortcuts.
|
||||||
|
|
||||||
There is only one IPC command as of now which can be used to get details about the currently active MPRIS player.
|
All IPC commands can be accessed via `caelestia shell ...`. For example
|
||||||
```sh
|
```sh
|
||||||
caelestia shell mpris getActive <prop>
|
caelestia shell mpris getActive trackTitle
|
||||||
|
```
|
||||||
|
|
||||||
|
The list of IPC commands can be shown via `caelestia shell help`:
|
||||||
|
```
|
||||||
|
> caelestia shell help
|
||||||
|
target mpris
|
||||||
|
function stop(): void
|
||||||
|
function play(): void
|
||||||
|
function next(): void
|
||||||
|
function getActive(prop: string): string
|
||||||
|
function list(): string
|
||||||
|
function playPause(): void
|
||||||
|
function pause(): void
|
||||||
|
function previous(): void
|
||||||
|
target drawers
|
||||||
|
function list(): string
|
||||||
|
function toggle(drawer: string): void
|
||||||
|
target wallpaper
|
||||||
|
function list(): string
|
||||||
|
function get(): string
|
||||||
|
function set(path: string): void
|
||||||
|
target notifs
|
||||||
|
function clear(): void
|
||||||
```
|
```
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import "root:/widgets"
|
import "root:/widgets"
|
||||||
import "root:/services"
|
import "root:/services"
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -34,4 +35,22 @@ Scope {
|
||||||
description: "Interrupt launcher keybind"
|
description: "Interrupt launcher keybind"
|
||||||
onPressed: root.launcherInterrupted = true
|
onPressed: root.launcherInterrupted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "drawers"
|
||||||
|
|
||||||
|
function toggle(drawer: string): void {
|
||||||
|
if (list().split("\n").includes(drawer)) {
|
||||||
|
const visibilities = Visibilities.getForActive();
|
||||||
|
visibilities[drawer] = !visibilities[drawer];
|
||||||
|
} else {
|
||||||
|
console.warn(`[IPC] Drawer "${drawer}" does not exist`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function list(): string {
|
||||||
|
const visibilities = Visibilities.getForActive();
|
||||||
|
return Object.keys(visibilities).filter(k => typeof visibilities[k] === "boolean").join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ pragma ComponentBehavior: Bound
|
||||||
import "root:/widgets"
|
import "root:/widgets"
|
||||||
import "root:/config"
|
import "root:/config"
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
import Quickshell.Services.Notifications
|
import Quickshell.Services.Notifications
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
|
|
@ -42,6 +43,15 @@ Singleton {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "notifs"
|
||||||
|
|
||||||
|
function clear(): void {
|
||||||
|
for (const notif of root.list)
|
||||||
|
notif.popup = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
component Notif: QtObject {
|
component Notif: QtObject {
|
||||||
id: notif
|
id: notif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,5 +55,43 @@ Singleton {
|
||||||
const active = root.active;
|
const active = root.active;
|
||||||
return active ? active[prop] ?? "Invalid property" : "No active player";
|
return active ? active[prop] ?? "Invalid property" : "No active player";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function list(): string {
|
||||||
|
return root.list.map(p => p.identity).join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function play(): void {
|
||||||
|
const active = root.active;
|
||||||
|
if (active?.canPlay)
|
||||||
|
active.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
function pause(): void {
|
||||||
|
const active = root.active;
|
||||||
|
if (active?.canPause)
|
||||||
|
active.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
function playPause(): void {
|
||||||
|
const active = root.active;
|
||||||
|
if (active?.canTogglePlaying)
|
||||||
|
active.togglePlaying();
|
||||||
|
}
|
||||||
|
|
||||||
|
function previous(): void {
|
||||||
|
const active = root.active;
|
||||||
|
if (active?.canGoPrevious)
|
||||||
|
active.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
function next(): void {
|
||||||
|
const active = root.active;
|
||||||
|
if (active?.canGoNext)
|
||||||
|
active.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop(): void {
|
||||||
|
root.active?.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,22 @@ Singleton {
|
||||||
|
|
||||||
reloadableId: "wallpapers"
|
reloadableId: "wallpapers"
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "wallpaper"
|
||||||
|
|
||||||
|
function get(): string {
|
||||||
|
return root.actualCurrent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set(path: string): void {
|
||||||
|
root.setWallpaper(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
function list(): string {
|
||||||
|
return root.list.map(w => w.path).join("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
path: root.currentNamePath
|
path: root.currentNamePath
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
|
|
@ -76,7 +92,7 @@ Singleton {
|
||||||
|
|
||||||
property string path
|
property string path
|
||||||
|
|
||||||
command: ["caelestia", "wallpaper", "-f", path]
|
command: ["caelestia", "wallpaper", "-Q", "-f", path]
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue