Skip to main content

Theme

Struct Theme 

Source
pub struct Theme {
Show 19 fields pub wallpaper: Option<PathBuf>, pub background: Color, pub surface: Color, pub foreground: Color, pub accent: Color, pub error: Color, pub font: String, pub mono_font: String, pub font_size: f32, pub clock_format: String, pub date_format: String, pub rounding: u32, pub dim: f32, pub blur: u32, pub font_scale: f32, pub warning: Color, pub success: Color, pub info: Color, pub surfaces: Surfaces,
}
Expand description

How the authentication screen looks.

Every field has a usable default, because a greeter that fails to render is a machine nobody can log into. A missing export, an unreadable wallpaper and a half-written file all have to degrade to “plain but working” rather than to nothing.

Fields§

§wallpaper: Option<PathBuf>

Full path to the background image. None renders Self::background flat, which is also the fallback when the file can’t be read.

§background: Color

Behind everything, and behind the wallpaper while it loads.

§surface: Color

The panel the prompt sits on.

§foreground: Color

Text on surface.

§accent: Color

The focused/active colour — the same one window borders use.

§error: Color

Failure text.

§font: String

Font family name, as gsettings reports it. Not a path — the renderer resolves it through the system’s own font lookup, the same as every other app on the desktop.

§mono_font: String

Monospace family, as gsettings’ monospace-font-name reports it — for config lines, keys and values shown as they are written.

Empty means “the toolkit’s own monospace”, and is the default on purpose rather than "Monospace": that name is a fontconfig alias, and a renderer that looks families up by name rather than through fontconfig finds no family called that and falls back to the proportional default — which is the one font this field exists to avoid. For the same reason a family that isn’t installed resolves to empty too — gsettings will name one that isn’t.

§font_size: f32

Base point size before Self::font_scale is applied.

§clock_format: String

strftime format for the clock. Empty hides it.

§date_format: String

strftime format for the date, shown alongside the clock. Empty hides it, same as Self::clock_format.

§rounding: u32

Corner radius, so the prompt matches window rounding.

§dim: f32

How much the wallpaper is dimmed behind the prompt, 0.0 to 1.0.

§blur: u32

Blur radius behind the prompt. 0 disables it.

§font_scale: f32

Scale applied to every text size, following the desktop’s own accessibility setting rather than a control of ours.

§warning: Color

Warnings — a setting that won’t take effect, a conflicting bind.

§success: Color

Confirmation that something applied.

§info: Color

“This is somewhere else” — a remote host, a mounted share, a network location.

Not a fifth shade of warning. It sits alongside Self::warning, Self::success and Self::error as a state colour, and it exists because the file manager’s design reserves colour so that colour always means something: green for good, orange for attention, red for danger, and this for not-local. Without it a mounted share would have to borrow one of the other three and quietly stop meaning what it says.

Dracula’s own cyan, unadjusted — the same choice Self::accent and Self::error already make, and it holds contrast against all four surfaces in the ramp.

§surfaces: Surfaces

The elevation ramp the window apps are built from. The auth screen only needs background and surface; a settings window needs the steps in between.

Implementations§

Source§

impl Theme

Source

pub fn drawable_font_size(&self) -> f32

This theme’s font size, clamped to something that can actually be drawn.

iced_tiny_skia/cosmic-text assert a non-zero line height, so a font size of 0.0 panics on the first frame — and the theme is read from a file a person can edit, so 0 is reachable.

It lives here rather than in each host because it was copied into three of them (the clipboard popup, the emoji popup and the tray menu). The clipboard’s own copy said so: “if a third host ever needs these bounds, they belong beside Theme in hyprforge-look rather than being copied a third time”. The third host arrived.

Source

pub fn corner_radius(&self) -> f32

This theme’s corner rounding, bounded.

Hyprland’s own decoration:rounding has no upper limit, and a huge one turns a popup into a lozenge or a circle. Same reason and same three copies as Theme::drawable_font_size.

Source

pub fn load(path: &Path) -> Result<Theme, ThemeError>

Reads a theme from path.

A missing file is the default theme, not an error: the greeter runs before anything has necessarily been exported, and refusing to draw would mean refusing to let anyone log in.

Source

pub fn load_exported() -> Theme

Reads the theme exported to export_dir, falling back to the default.

Never returns an error. A greeter has nobody to report one to and nothing better to do than draw something usable — so a corrupt or unreadable export degrades to plain rather than to a blank screen.

No current caller: hyprforge-greet needs the --theme-dir override that load_exported_from takes and this fixed path doesn’t, so it calls that instead. Kept for any other host that only ever reads the one export (hyprforge-authui consumers besides the greeter, should one exist).

Source

pub fn load_exported_from(dir: &Path) -> Theme

load_exported against a named directory.

Split out so the degrade-to-default behaviour can be tested without reading a real system path — and so a caller with its own notion of where the export lives, like hyprforge-greet’s --theme-dir, can use it too. The test that read a real path instead asserted the export “won’t exist in a test environment”, which stopped being true the moment the greeter was installed on the machine running the tests — it then failed because the product was working.

Source

pub fn save(&self, path: &Path) -> Result<(), ThemeError>

Writes the theme to path, as the lock screen reads it.

The wallpaper path is stored as-is, because the reader runs as the same user and can follow it. export is the version for a reader that cannot.

Source

pub fn export(&self, dir: &Path) -> Result<Theme, ThemeError>

Writes the theme and a copy of its wallpaper into dir.

The wallpaper is copied, and the stored path rewritten to the copy. Referring to the original would leave the greeter with a path it cannot traverse — the failure this whole module exists to avoid — and it would break again the moment the image moved.

Returns the theme as written, which is not the theme passed in: its wallpaper path points at the copy.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Theme

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Theme

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Theme
where Theme: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Theme

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Theme

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.