add option to blur the whole background

This commit is contained in:
Alexander Mohr 2025-06-02 22:39:23 +02:00
parent 7d0cc569b7
commit c2efd66d6c
10 changed files with 142 additions and 7 deletions

View file

@ -355,7 +355,7 @@ fn main() -> Result<(), String> {
// will exit if there is a daemon running already, so it's fine to call this everytime.
if let Err(e) = spawn_fork("ydotoold", None) {
log::error!("Failed to start ydotool daemon: {e}");
log::error!("Failed to start ydotool daemon: {e}");
}
// todo eventually use a propper rust client for this, for now rbw is good enough

View file

@ -1,6 +1,10 @@
* {
font-family: DejaVu;
transition: opacity 500ms ease;
font-family: DejaVu;
transition: opacity 500ms ease;
}
#background {
background-color: rgba(33, 33, 33, 0.1);
}
#window {

View file

@ -2,6 +2,10 @@
font-family: DejaVu;
}
#background {
background-color: rgba(33, 33, 33, 0.1);
}
#window {
all: unset;
background-color: rgba(33, 33, 33, 0.8); /* Matches #212121BB */

View file

@ -6,5 +6,5 @@ content_halign="Center"
height="70%"
width="60%"
valign="Start"
#line_wrap="Word"
blurred_background=true
line_max_chars=32

View file

@ -2,6 +2,10 @@
font-family: DejaVu;
}
#background {
background-color: rgba(33, 33, 33, 0.1);
}
#window {
all: unset;
background-color: rgba(33, 33, 33, 0.8); /* Matches #212121BB */

8
styles/math/config.toml Normal file
View file

@ -0,0 +1,8 @@
image_size=28
allow_images=false
term="kitty -e"
insensitive=true
key_detection_type="Code"
blurred_background=false
location=["Top"]
lines=3

86
styles/math/style.css Normal file
View file

@ -0,0 +1,86 @@
* {
font-family: DejaVu;
transition: opacity 500ms ease;
}
#background {
background-color: rgba(33, 33, 33, 0.1);
}
#window {
all: unset;
background-color: rgba(33, 33, 33, 0.8); /* Matches #212121BB */
border-radius: 0px;
}
#window #outer-box {
/* The name of the search bar */
/* The name of the scrolled window containing all of the entries */
border: 2px solid rgba(63, 81, 181, 1);
border-radius: 6px;
}
#window #outer-box #input {
background-color: rgba(32, 32, 32, 0.6);
color: #f2f2f2;
border-bottom: 2px solid rgba(214, 174, 0, 1);
padding: 0.8rem 1rem;
font-size: 1rem;
}
#window #outer-box #input:focus, #window #outer-box #input:focus-visible, #window #outer-box #input:active {
all: unset;
background-color: rgba(32, 32, 32, 0.6);
color: #f2f2f2;
border-bottom: 2px solid rgba(214, 174, 2, 1);
padding: 1.2rem;
padding-left: 1rem;
font-size: 1rem;
}
#window #outer-box #scroll {
border-top: 2px solid rgba(214, 174, 0, 1);
}
#window #outer-box #scroll #inner-box {
/* The name of all entries */
/* The name of all boxes shown when expanding */
/* entries with multiple actions */
}
#window #outer-box #scroll #inner-box #entry {
color: #fff;
background-color: rgba(32, 32, 32, 0.1);
padding: 0.6rem 1rem;
/* The name of all images in entries displayed in image mode */
/* The name of all the text in entries */
}
#window #outer-box #scroll #inner-box #entry #img {
margin-right: 0.5rem;
}
#window #outer-box #scroll #inner-box #entry:selected {
color: #fff;
background-color: rgba(255, 255, 255, 0.1);
outline: none;
}
#row:hover {
background-color: rgba(255, 255, 255, 0);
outline: inherit;
outline-color: inherit;
}
#window #outer-box #scroll #inner-box #entry:hover {
background-color: rgba(255, 255, 255, 0.1);
outline: inherit;
outline-color: inherit;
}
#custom-key-label-box {
margin-top: 0.25em;
margin-bottom: 0.25em;
border-right: 1px solid rgba(214, 174, 0, 1);
border-left: 1px solid rgba(214, 174, 0, 1);
padding-left: 1em;
}
#custom-key-hint-text {
margin-left: 0.75em;
}

View file

@ -2,6 +2,10 @@
font-family: DejaVu;
}
#background {
background-color: rgba(33, 33, 33, 0.1);
}
#window {
all: unset;
background-color: rgba(33, 33, 33, 0.8); /* Matches #212121BB */

View file

@ -421,6 +421,11 @@ pub struct Config {
/// Defaults to `<https://duckduckgo.com/?q=>`
#[clap(long = "search-query")]
search_query: Option<String>,
/// Blur the background of the screen
/// can be style via `background`
#[clap(long = "blurred-background")]
blurred_background: Option<bool>,
}
impl Config {
@ -663,6 +668,11 @@ impl Config {
.clone()
.unwrap_or_else(|| "https://duckduckgo.com/?q=".to_owned())
}
#[must_use]
pub fn blurred_background(&self) -> bool {
self.blurred_background.unwrap_or(false)
}
}
fn default_false() -> bool {

View file

@ -680,8 +680,6 @@ fn build_ui<T, P>(
log::debug!("keyboard ready after {:?}", start.elapsed());
ui_elements.window.set_widget_name("window");
if !config.normal_window() {
// Initialize the window as a layer
ui_elements.window.init_layer_shell();
@ -689,9 +687,11 @@ fn build_ui<T, P>(
ui_elements
.window
.set_keyboard_mode(KeyboardMode::Exclusive);
ui_elements.window.set_namespace(Some("worf"));
}
ui_elements.window.set_widget_name("window");
ui_elements.window.set_namespace(Some("worf"));
if let Some(location) = config.location() {
for anchor in location {
ui_elements.window.set_anchor(anchor.into(), true);
@ -742,6 +742,21 @@ fn build_ui<T, P>(
let window_start = Instant::now();
ui_elements.window.present();
if config.blurred_background() {
let background = ApplicationWindow::builder()
.decorated(false)
.resizable(false)
.fullscreened(true)
// arbitrary huge window so it fills the whole screen
.default_width(100_000)
.default_height(100_000)
.build();
background.set_widget_name("background");
background.set_namespace(Some("worf"));
background.present();
}
log::debug!("window show took {:?}", window_start.elapsed());
log::debug!("Building UI took {:?}", start.elapsed(),);