Skip to main content

Module system_values

Module system_values 

Source
Expand description

System values (notes/system_signals.md, P136): battery (percent), charging, online and dark mode read the machine’s state through the host word system_value(name), an i64 (booleans 0 or 1). Listeners on them (whenever battery < 20% {…}) compare readings at the program’s check points, so a reading is kept for READING_LIFETIME: a sleeping program polls often, the platform is asked at most once a second per value. macOS asks pmset and defaults, Linux /sys and gsettings; online is whether a route to the internet exists (a UDP connect sends nothing). A value the platform cannot give is a loud error, never a made-up reading. mouse_x, mouse_y, mouse_down: natively the pointer over the paint window (window_input), read each time; mouse_wheel the wheel steps turned over it (wheel); key_down whether a key is held over it, key code held which (lowering/signals/system_values.rs names it held_key); window_open whether that window shows; read before any paint, it opens the window (blank) where one can show. window_width, window_height (window.width, card make-width): the paint window’s inner size in points as it reports it, else as last written, else the view’s; writing one resizes the window through the warp binary’s resizer. display_width, display_height: the main screen’s size in points, read only; display_dpi its device pixels per inch (CoreGraphics’ physical size, xrandr’s millimetres), read only. The clipboard is watched by its change count, which reads no content: macOS asks the user before a program reads what another one copied, so the text is read only when the program asks for it (clipboard, clipboard_text).

Functions§

clipboard_text
The clipboard’s text: macOS pbpaste, Linux wl-paste or xclip
escape_kept
held_among
Whether the key of that code is the key held or among the keys held; code 0: whether none is
key_held
Whether the key of that code is held now, among others (KEY_HELD); code 0: whether none is
native_view
view_width × view_height before any window shows a picture
notify
notify "text": a desktop notification, macOS through osascript, Linux notify-send; the text goes as an argument, so no quoting can break it
read
The current value of a system value, read anew at most once per READING_LIFETIME
tell_gpu_drawing
tell_gpu_painter
tell_keys_held
tell_wheel
tell_window_input
tell_window_key
The key held over the paint window alone, the pointer left as it is
tell_window_open
tell_window_opener
tell_window_resizer
tell_window_size
The window’s size as it reports it (src/graphics/paint_window.rs follow_input)
wheel
window_input
window_shows
write
set_system_value(name, value): window.width = 800 resizes the window, display.dpi = 300 dpi sets the dots per inch px count in; the others are read only
write_clipboard
Puts text on the clipboard: macOS pbcopy, Linux wl-copy or xclip