pub trait ServicesExt {
Show 30 methods
// Required methods
fn clock(&self, precision: Precision) -> ReadSignal<Zoned>;
fn locale(&self) -> ReadSignal<Locale>;
fn sway(&self) -> Sway;
fn hyprland(&self) -> Hyprland;
fn niri(&self) -> Niri;
fn audio(&self) -> Audio;
fn tray(&self) -> TrayHost;
fn upower(&self) -> UPower;
fn power_profiles(&self) -> PowerProfiles;
fn bluetooth(&self) -> Bluetooth;
fn bluetooth_agent(&self) -> BluetoothAgent;
fn notifications(&self) -> Notifications;
fn mpris(&self) -> Mpris;
fn network(&self) -> Network;
fn socket(&self, path: impl Into<PathBuf>) -> Socket;
fn socket_server(&self, path: impl Into<PathBuf>) -> SocketServer;
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 folder_view(&self, path: impl IntoProp<PathBuf>) -> FolderView;
fn system_stats(&self, period: Duration) -> ReadSignal<SystemStats>;
fn greetd(&self) -> Greetd;
fn json_file<T>(&self, path: impl Into<PathBuf>, default: T) -> Signal<T>
where T: Serialize + DeserializeOwned + PartialEq + 'static;
fn http_get(&self, url: impl IntoProp<String>) -> Http;
fn cover_art(
&self,
url: impl IntoProp<String>,
) -> ReadSignal<Option<PathBuf>>;
fn desktop_entries(&self) -> DesktopEntries;
fn pam(&self, service: &str) -> Pam;
fn polkit_agent(&self) -> PolkitAgent;
fn logind(&self) -> Logind;
fn brightness(&self) -> Brightness;
}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 locale(&self) -> ReadSignal<Locale>
fn locale(&self) -> ReadSignal<Locale>
The month and day names of the user’s locale for dates: LC_ALL,
else LC_TIME, else LANG. English until glibc’s names for it are
read, once per shell, by running locale -k LC_TIME on a thread;
that wakes the shell once. C, POSIX, unset, or a locale that isn’t
installed stays English.
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 niri(&self) -> Niri
fn niri(&self) -> Niri
niri’s workspaces, windows, keyboard layouts and overview, from its
event stream on the IPC socket at $NIRI_SOCKET. Every caller
shares one connection, made on the first call.
The lists are empty while niri isn’t there: when NIRI_SOCKET is
unset or the socket is missing, they stay empty, which is logged
once, and the service never wakes the shell. When niri closes the
stream while its socket is still there, the shell connects once
again; otherwise the lists empty and nothing reconnects. While
connected, it wakes the shell only when niri 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, and while a peak meter from
Audio::peaks records.
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 bluetooth_agent(&self) -> BluetoothAgent
fn bluetooth_agent(&self) -> BluetoothAgent
The shell’s Bluetooth pairing agent: when BlueZ needs a PIN, a
passkey or a yes to pair a device, it asks the shell, and a config
shows the prompt. The first call registers the agent with BlueZ on
the system bus, as KeyboardDisplay, again whenever BlueZ starts
again; a shell that never calls it never answers BlueZ. Every caller
shares the one agent, which wakes the shell only when BlueZ calls.
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 socket_server(&self, path: impl Into<PathBuf>) -> SocketServer
fn socket_server(&self, path: impl Into<PathBuf>) -> SocketServer
A server on the Unix socket at path, as Quickshell’s
SocketServer: it listens at once, and each client that connects
becomes a Socket for SocketServer::on_connection. Each call
makes its own, which stops when this context goes, closing its
connections and removing its socket file. It wakes the shell only
when a client connects, 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. When
the compositor hands out activation tokens, it starts once one comes,
or after 100 ms without one, with the token in
XDG_ACTIVATION_TOKEN and DESKTOP_STARTUP_ID, so the compositor
may focus its window.
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 folder_view(&self, path: impl IntoProp<PathBuf>) -> FolderView
fn folder_view(&self, path: impl IntoProp<PathBuf>) -> FolderView
The folder at path, as Qt’s FolderListModel: its entries, read
at the next flush and again 50 ms after a change in it, so a burst
of changes reads it once, and followed as file_view follows a
file when the folder is made later, removed or replaced.
path takes a value or a closure; a new path follows the new
folder, and a panic in the closure is logged and empties the view
until the next change. Each call reads its own, which goes with
this context. It is read on the main thread, and wakes the shell
only when the folder changes.
Sourcefn system_stats(&self, period: Duration) -> ReadSignal<SystemStats>
fn system_stats(&self, period: Duration) -> ReadSignal<SystemStats>
CPU, memory and temperature stats, sampled at once and then every
period, at least 250 ms, from /proc and /sys/class/hwmon. Each
call samples on its own timer, which goes with this context, so
stats wake the shell only while a context that shows them lives.
Call it once, above per_output, and share the signal. The signal
starts empty and fills when the first sample, asked for at once,
comes back from the thread the reads run on, so a slow sensor never
holds up a frame. A tick while a read still runs is skipped. Each
sample wakes the shell twice: at the tick and when the answer comes.
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 http_get(&self, url: impl IntoProp<String>) -> Http
fn http_get(&self, url: impl IntoProp<String>) -> Http
Fetches url with an HTTP GET through curl, in a process of its
own, so nothing waits on the network. A closure fetches again when a
signal it read changes the URL. It stops when this context goes, and
wakes the shell only while curl runs.
Sourcefn cover_art(&self, url: impl IntoProp<String>) -> ReadSignal<Option<PathBuf>>
fn cover_art(&self, url: impl IntoProp<String>) -> ReadSignal<Option<PathBuf>>
The local file for the cover art at url, for an Image: a
file:// URL’s file, or an http: or https: URL’s picture
downloaded through curl into $XDG_CACHE_HOME/crabshell/art.
None while it downloads, and for anything else or a failure, which
is logged once per URL.
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.
Sourcefn logind(&self) -> Logind
fn logind(&self) -> Logind
logind on the system bus: when the machine is about to sleep, a
delay so a config can get ready first, as a lock screen locks, and
the power actions. Every caller shares one connection, which starts
on the loop’s next turn. It behaves as upower
does while logind isn’t there, and wakes the shell only for
PrepareForSleep.
Sourcefn brightness(&self) -> Brightness
fn brightness(&self) -> Brightness
The screen backlights in /sys/class/backlight, read on the first
call and followed with inotify, and set through logind, which
starts with it. Every caller shares one list. It wakes the shell
only when the kernel says a brightness changed; a backlight added
later shows after a restart.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".