pub trait ServicesExt {
Show 20 methods
// Required methods
fn clock(&self, precision: Precision) -> ReadSignal<Zoned>;
fn sway(&self) -> Sway;
fn hyprland(&self) -> Hyprland;
fn audio(&self) -> Audio;
fn tray(&self) -> TrayHost;
fn upower(&self) -> UPower;
fn power_profiles(&self) -> PowerProfiles;
fn bluetooth(&self) -> Bluetooth;
fn notifications(&self) -> Notifications;
fn mpris(&self) -> Mpris;
fn network(&self) -> Network;
fn socket(&self, path: impl Into<PathBuf>) -> Socket;
fn process<C: IntoCommand>(
&self,
command: impl Fn() -> C + 'static,
) -> Process;
fn exec_detached(&self, command: impl IntoCommand);
fn file_view(&self, path: impl Into<PathBuf>) -> FileView;
fn greetd(&self) -> Greetd;
fn json_file<T>(&self, path: impl Into<PathBuf>, default: T) -> Signal<T>
where T: Serialize + DeserializeOwned + PartialEq + 'static;
fn desktop_entries(&self) -> DesktopEntries;
fn pam(&self, service: &str) -> Pam;
fn polkit_agent(&self) -> PolkitAgent;
}Expand description
The services a context hands out.
Required Methods§
Sourcefn clock(&self, precision: Precision) -> ReadSignal<Zoned>
fn clock(&self, precision: Precision) -> ReadSignal<Zoned>
The time, truncated to precision: it changes on each whole second
or minute and holds the one just passed, in the system time zone.
Every caller asking for the same precision gets the same signal.
A minute clock wakes the shell once a minute and at no other time. After a suspend, and when timedated changes the time zone, it is right again at once. A zone changed any other way shows from the next tick.
Sourcefn sway(&self) -> Sway
fn sway(&self) -> Sway
Sway’s workspaces, outputs, commands and events, over the IPC socket
at $SWAYSOCK, as Quickshell’s I3. Every caller shares one
connection, made on the first call.
The lists are empty while Sway isn’t there. When SWAYSOCK is unset
or the first connect fails, they stay empty and the service never
wakes the shell. When a working connection closes, they are empty
until a reconnect, tried every 2 s, works. While connected, it wakes
the shell only for a workspace event, an output event once a config
asked for the outputs, and the kinds of event a handler asked for.
Sourcefn hyprland(&self) -> Hyprland
fn hyprland(&self) -> Hyprland
Hyprland’s workspaces, monitors and windows, over its IPC sockets
in $XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/. Every
caller shares one event connection, made on the first call.
The lists are empty while Hyprland isn’t there: when the signature is unset or its sockets are missing, they stay empty, which is logged once, and the service never wakes the shell. When Hyprland closes its event socket, the lists empty and nothing reconnects. While connected, it wakes the shell only when Hyprland sends something.
Sourcefn audio(&self) -> Audio
fn audio(&self) -> Audio
The audio server’s default sink, with its volume and mute. Every caller shares one connection, which starts on the loop’s next turn and never waits for the server. It wakes the shell only when the server reports a change.
With no server, the sink is None and the service tries again
every 2 s, for up to a minute after startup and after each drop of
a working connection. Then it stops, logs that once and never wakes
the shell again; a restart tries again.
Sourcefn tray(&self) -> TrayHost
fn tray(&self) -> TrayHost
The system tray: every app’s StatusNotifierItem on the session bus. Every caller shares one connection, which starts on the loop’s next turn and never waits for the bus.
The shell runs the StatusNotifierWatcher while no other program does, and otherwise reads the list from the one that runs, taking over when it leaves. With no session bus the list stays empty and the service never wakes the shell. It wakes the shell only when something arrives on the bus for it.
Sourcefn upower(&self) -> UPower
fn upower(&self) -> UPower
UPower’s batteries and power supplies, on the system bus. Every caller shares one connection, which starts on the loop’s next turn.
While UPower isn’t running the lists are empty, and they fill when it starts. With no system bus they stay empty and the service never wakes the shell. It wakes the shell only when UPower says something changed.
Sourcefn power_profiles(&self) -> PowerProfiles
fn power_profiles(&self) -> PowerProfiles
The power profile, from power-profiles-daemon on the system bus.
Every caller shares one connection. It behaves as
upower does while the daemon isn’t there.
Sourcefn bluetooth(&self) -> Bluetooth
fn bluetooth(&self) -> Bluetooth
Bluetooth adapters and devices, from BlueZ on the system bus. Every
caller shares one connection. It behaves as upower
does while BlueZ isn’t there, and wakes the shell only when BlueZ
says something changed.
Sourcefn notifications(&self) -> Notifications
fn notifications(&self) -> Notifications
The notification server on the session bus: what apps sent, and the popups still showing. Every caller shares one connection, which starts on the loop’s next turn and never waits for the bus.
The shell serves while no other program does. While another daemon has the name, the shell waits for it to leave, and keeps what it was sent if one takes the name over. With no session bus the lists stay empty and the service never wakes the shell. It wakes the shell only when an app calls and when a popup expires.
Sourcefn mpris(&self) -> Mpris
fn mpris(&self) -> Mpris
The media players on the session bus, over MPRIS, such as a music player or a browser playing a video. Every caller shares one connection, which starts on the loop’s next turn and never waits for the bus.
With no session bus the list stays empty and the service never
wakes the shell. It wakes the shell only when a player says
something changed. MPRIS doesn’t say when the position moves, so a
bar works it out with Player::position_at.
Sourcefn network(&self) -> Network
fn network(&self) -> Network
Network devices and Wi-Fi networks, from NetworkManager on the
system bus. Every caller shares one connection. It behaves as
upower does while NetworkManager isn’t there, and
wakes the shell only when NetworkManager says something changed.
Sourcefn socket(&self, path: impl Into<PathBuf>) -> Socket
fn socket(&self, path: impl Into<PathBuf>) -> Socket
A connection to the Unix socket at path, made at once, as
Quickshell’s Socket. Each call opens its own, which closes when
this context goes. It wakes the shell only when the other end sends
something or takes what was written.
Sourcefn process<C: IntoCommand>(&self, command: impl Fn() -> C + 'static) -> Process
fn process<C: IntoCommand>(&self, command: impl Fn() -> C + 'static) -> Process
Runs the program command builds, as Quickshell’s Process, and
keeps what it prints and how it ended. command returns a
Command or a list such as
["uptime", "-p"]. It starts on the loop’s next turn, and again
whenever a signal command read changes or Process::restart is
called, stopping the run before. It is stopped when this context
goes. It wakes the shell only when the program prints, takes input
or ends.
Sourcefn exec_detached(&self, command: impl IntoCommand)
fn exec_detached(&self, command: impl IntoCommand)
Starts command and lets it run on its own, as a launcher does:
its input and outputs are empty, it has a process group of its own,
and it is reaped when it ends. A failure to start is logged.
Sourcefn file_view(&self, path: impl Into<PathBuf>) -> FileView
fn file_view(&self, path: impl Into<PathBuf>) -> FileView
The text file at path, as Quickshell’s FileView: read now, and
again when it changes on disk. Each call reads its own, which goes
with this context. It is read on the main thread, so a file on a
slow disk delays the frame.
Sourcefn greetd(&self) -> Greetd
fn greetd(&self) -> Greetd
greetd, for a greeter: makes a session for a user, answers its
questions and starts it, over the socket GREETD_SOCK names. One
connection per shell, made at the first request; it wakes the shell
only when greetd answers.
Sourcefn json_file<T>(&self, path: impl Into<PathBuf>, default: T) -> Signal<T>
fn json_file<T>(&self, path: impl Into<PathBuf>, default: T) -> Signal<T>
A value kept in the JSON file at path, as Quickshell’s
JsonAdapter: default until the file is read, the file’s value
once it is, and the file rewritten whenever the config sets another.
A missing file, and its directory, is made at the first set. A file
that isn’t T’s
JSON is logged and left alone, and the value stays.
Sourcefn desktop_entries(&self) -> DesktopEntries
fn desktop_entries(&self) -> DesktopEntries
The installed applications, from the desktop entries in the XDG data directories: what a launcher lists and starts, and where a window’s app id finds its icon. Every caller shares one list, read on the loop’s next turn after the first call.
The directories are watched, and the list is read again once the files have been still for 100 ms after a change. It wakes the shell at no other time.
Sourcefn pam(&self, service: &str) -> Pam
fn pam(&self, service: &str) -> Pam
Authentication through the PAM service service, the name of a
file in /etc/pam.d, as a lock screen asks for the user’s
password. Each call has its own, which goes with this context.
Nothing runs until Pam::start. Each attempt runs on a thread of
its own, since libpam blocks, and wakes the shell only when PAM asks
or says something, or the attempt ends. After a success PAM’s
account step runs too, which clears pam_faillock’s count of past
failures; its refusal is only logged. An attempt ended while PAM
waits for an answer counts as a failure, as Pam::start says.
Sourcefn polkit_agent(&self) -> PolkitAgent
fn polkit_agent(&self) -> PolkitAgent
The shell’s polkit authentication agent, as Quickshell’s
PolkitAgent: when a program asks polkit for something only some
users may do, its request shows here for the config’s dialog. The
first call registers the agent with polkit on the system bus for
this session; a shell that never calls it never reaches polkit.
A refused registration is logged and no requests arrive. It wakes the shell only when polkit calls and while a request is answered.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".