### Run Eww Daemon and Open Widget Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Start the Eww daemon and then open a widget by its name. Ensure the Eww binary is in your PATH or run from its directory. ```bash ./eww daemon ./eww open ``` -------------------------------- ### Build Eww for X11 Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Build the Eww project in release mode with X11 features enabled. Ensure you have the necessary prerequisites installed. ```bash cargo build --release --no-default-features --features x11 ``` -------------------------------- ### Start Eww Daemon Source: https://context7.com/elkowar/eww/llms.txt Launches the Eww daemon process. Options include enabling debug logging or specifying a custom configuration directory. ```bash # Start the daemon ewww daemon # Start with debug logging ewww --debug daemon # Start with custom config directory ewww --config /path/to/config daemon ``` -------------------------------- ### Complete Status Bar Example Source: https://context7.com/elkowar/eww/llms.txt A full status bar configuration demonstrating various Eww concepts like variables, polling, listening, custom widgets, and window definitions. Requires Eww and potentially `wmctrl` and `playerctl`. ```lisp ; eww.yuck - Complete bar example ; Variables (defvar volume 50) (defvar show_calendar false) ; Polling variables (defpoll time :interval "1s" "date '+%H:%M'") (defpoll date :interval "60s" "date '+%b %d, %Y'") ; Listening variable for music (deflisten music :initial "" "playerctl --follow metadata --format '{{artist}} - {{title}}' || true") ; Custom widgets (defwidget workspaces [] (box :class "workspaces" :orientation "h" :spacing 5 (for i in `[1,2,3,4,5,6,7,8,9]` (button :class "workspace" :onclick "wmctrl -s ${i - 1}" i)))) (defwidget music-widget [] (box :class "music" :visible {music != ""} (label :text {music} :limit-width 40 :truncate true))) (defwidget volume-slider [] (box :class "volume" :orientation "h" :space-evenly false :spacing 5 (label :text "") (scale :min 0 :max 100 :value volume :onchange "pamixer --set-volume {}"))) (defwidget system-info [] (box :class "system-info" :orientation "h" :space-evenly false :spacing 15 (label :text "CPU: ${round(EWW_CPU.avg, 0)}%") (label :text "RAM: ${round(EWW_RAM.used_mem_perc, 0)}%") (label :text "DISK: ${round(EWW_DISK['/'].used_perc, 0)}%"))) (defwidget clock [] (eventbox :onclick "eww update show_calendar=${!show_calendar}" (box :class "clock" :orientation "h" :space-evenly false :spacing 10 (label :text time) (label :text date)))) (defwidget bar-layout [] (centerbox :orientation "h" (box :halign "start" (workspaces)) (box :halign "center" (music-widget)) (box :halign "end" :space-evenly false :spacing 20 (system-info) (volume-slider) (clock)))) ; Window definition (defwindow bar :monitor 0 :windowtype "dock" :geometry (geometry :x "0%" :y "5px" :width "98%" :height "35px" :anchor "top center") :reserve (struts :side "top" :distance "45px") :stacking "fg" :exclusive true (bar-layout)) ; Calendar popup (defwindow calendar-popup :monitor 0 :geometry (geometry :x "0px" :y "50px" :anchor "top right") :stacking "fg" (calendar :show-heading true :show-day-names true)) ``` -------------------------------- ### Organizing Eww Configuration with Includes Source: https://context7.com/elkowar/eww/llms.txt Demonstrates how to split a large Eww configuration into multiple files using the `include` directive for better organization. This approach helps manage complex setups by separating different components like widgets, variables, and windows. ```lisp ; eww.yuck - main entry point (include "./widgets/bar.yuck") (include "./widgets/dashboard.yuck") (include "./variables.yuck") (include "./windows.yuck") ; Or use separate config directories ; eww --config ~/.config/eww-bar open bar ; eww --config ~/.config/eww-dashboard open dashboard ``` -------------------------------- ### Define a Basic Eww Window Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use `defwindow` to declare a window with properties like monitor, geometry, and content. This is the starting point for creating any visible element in Eww. ```lisp (defwindow example :monitor 0 :geometry (geometry :x "0%" :y "20px" :width "90%" :height "30px" :anchor "top center") :stacking "fg" :reserve (struts :distance "40px" :side "top") :windowtype "dock" :wm-ignore false "example content") ``` -------------------------------- ### Build Eww for Wayland Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Build the Eww project in release mode with Wayland features enabled. This is for Wayland environments. Ensure you have the necessary prerequisites installed. ```bash cargo build --release --no-default-features --features=wayland ``` -------------------------------- ### Basic GTK CSS Stylesheet Source: https://context7.com/elkowar/eww/llms.txt An example SCSS stylesheet for Eww, demonstrating how to reset all styles, style the main window, apply class-based styling, and customize individual widget appearances like buttons, scales, progress bars, and labels. Includes hover and active states. ```scss // Reset all styles * { all: unset; } // Window styling window { background-color: rgba(30, 30, 46, 0.9); } // Class-based styling .bar { background-color: #1e1e2e; color: #cdd6f4; padding: 10px; border-radius: 10px; } // Widget-specific styling button { background-color: #313244; padding: 5px 10px; border-radius: 5px; &:hover { background-color: #45475a; } &:active { background-color: #585b70; } } // Scale/slider styling scale { trough { background-color: #313244; border-radius: 5px; min-height: 8px; min-width: 100px; } highlight { background-color: #89b4fa; border-radius: 5px; } slider { background-color: #cdd6f4; border-radius: 50%; min-width: 12px; min-height: 12px; } } // Progress bar styling progressbar { trough { background-color: #313244; border-radius: 5px; min-height: 10px; } progress { background-color: #a6e3a1; border-radius: 5px; } } // Circular progress styling circular-progress { background-color: #313244; color: #89b4fa; // progress color padding: 2px; } // Label styling label { color: #cdd6f4; font-family: "JetBrains Mono"; font-size: 14px; } // Eventbox with CSS states eventbox { &:hover { background-color: rgba(255, 255, 255, 0.1); } &:active { background-color: rgba(255, 255, 255, 0.2); } } ``` -------------------------------- ### Display Widgets in Lisp Source: https://context7.com/elkowar/eww/llms.txt Examples of using Lisp to define various display widgets like labels, images, progress bars, and graphs. Includes configuration for text formatting, image sources, and progress visualization. ```lisp (label :text "Hello World" :markup "Bold and italic" :wrap true :truncate true :limit-width 20 :show-truncated true :angle 0 :xalign 0.5 :yalign 0.5 :justify "left") ``` ```lisp (image :path "/path/to/image.png" :image-width 100 :image-height 100 :preserve-aspect-ratio true) ``` ```lisp (image :icon "firefox" :icon-size "dialog") ; menu, small-toolbar, large-toolbar, button, dnd, dialog ``` ```lisp (image :path "/path/to/icon.svg" :fill-svg "#ff5500" :image-width 24 :image-height 24) ``` ```lisp (progress :value {battery_percent} :orientation "horizontal" :flipped false) ``` ```lisp (circular-progress :value {cpu_usage} :thickness 4 :start-at 75 :clockwise true) ``` ```lisp (graph :value {cpu_usage} :thickness 2 :time-range "60s" :min 0 :max 100 :dynamic false :line-style "round" :flip-x false :flip-y false) ``` -------------------------------- ### Define a Reusable Widget with Parameters Source: https://context7.com/elkowar/eww/llms.txt Use `defwidget` to create custom, reusable UI components. This example shows a widget with required and optional parameters. ```lisp ; Widget with required and optional parameters (defwidget greeter [name ?text] (box :orientation "horizontal" :halign "center" text (button :onclick "notify-send 'Hello' 'Hello, ${name}'" "Greet"))) ``` -------------------------------- ### JSON Access Example Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Demonstrates accessing fields within a JSON structure stored in a variable. Supports dot notation, bracket notation with string keys, and bracket notation with numeric indices. ```lisp json_variable.field_name ``` ```lisp json_variable["field_name"] ``` ```lisp json_variable[12] ``` -------------------------------- ### Dynamic Content Generation with Loops in Lisp Source: https://context7.com/elkowar/eww/llms.txt Shows how to generate widgets dynamically from JSON arrays using Lisp's 'for' loop. Examples include creating buttons based on workspace data and labels from a simple item list. Uses conditional classes and onclick events. ```lisp (defvar workspaces `[ {"id": 1, "name": "main", "active": true}, {"id": 2, "name": "web", "active": false}, {"id": 3, "name": "code", "active": false} ]`) (box :orientation "horizontal" (for ws in workspaces (button :class {ws.active ? "active" : ""} :onclick "wmctrl -s ${ws.id - 1}" {ws.name}))) ; Simple array iteration (defvar items `["Item 1", "Item 2", "Item 3"]`) (box (for item in items (label :text item))) ``` -------------------------------- ### Display CPU Temperature using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Use the `EWW_TEMPS` magic variable to display CPU temperature. This example accesses the temperature for 'CPU'. ```lisp ; Temperature information (updates every 2s) ; EWW_TEMPS = {"CPU": 45.0, "GPU": 50.0, ...} (label :text "Temp: ${EWW_TEMPS.CPU}C") ``` -------------------------------- ### Display Battery Status using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Use the `EWW_BATTERY` magic variable to show the battery capacity. This example accesses the status for 'BAT0'. ```lisp ; Battery information (updates every 2s) ; EWW_BATTERY = {"BAT0": {"capacity": 85, "status": "Charging"}, "total_avg": 85} (label :text "Battery: ${EWW_BATTERY.BAT0.capacity}%") ``` -------------------------------- ### Conditional Expression Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Example of a conditional expression (ternary operator). It evaluates a condition and returns one of two values based on the boolean result. ```lisp condition ? 'value' : 'other value' ``` -------------------------------- ### Build Eww from Source Source: https://context7.com/elkowar/eww/llms.txt Build Eww for X11 or Wayland display servers from source using Cargo. Ensure the executable is made and then run the daemon. ```bash # Clone the repository git clone https://github.com/elkowar/eww cd eww # Build for X11 cargo build --release --no-default-features --features x11 # Build for Wayland cargo build --release --no-default-features --features wayland # Make executable and run chmod +x ./target/release/eww ./target/release/eww daemon ``` -------------------------------- ### Use a Custom Greeter Widget in a Window Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Demonstrates how to instantiate the custom 'greeter' widget within a window definition, providing the necessary 'name' attribute and an optional 'text' attribute. ```lisp (defwindow example ; ... values omitted (greeter :text "Say hello!" :name "Tim")) ``` -------------------------------- ### Navigate to Build Directory Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Change the current directory to the release build output directory. ```bash cd target/release ``` -------------------------------- ### Navigate to Eww Directory Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Change the current directory to the cloned Eww repository. ```bash cd eww ``` -------------------------------- ### Use a Widget with Parameters Source: https://context7.com/elkowar/eww/llms.txt Instantiate a previously defined widget by providing its required and optional parameters. ```lisp ; Using the widget (greeter :text "Say hello!" :name "Tim") ``` -------------------------------- ### Make Eww Executable Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Grant execute permissions to the Eww binary. ```bash chmod +x ./eww ``` -------------------------------- ### Define a Listening Variable for Workspace Changes Source: https://context7.com/elkowar/eww/llms.txt Use `deflisten` to track changes in system workspaces by running a custom script. ```lisp ; Monitor workspaces (deflisten workspaces :initial "[]" "~/.config/eww/scripts/get-workspaces") ``` -------------------------------- ### Define a Custom Greeter Widget Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Creates a reusable 'greeter' widget that accepts optional text and a required name. It uses a box to contain text and a button, demonstrating string interpolation for dynamic button text. ```lisp (defwidget greeter [?text name] (box :orientation "horizontal" :halign "center" text (button :onclick "notify-send 'Hello' 'Hello, ${name}'" "Greet"))) ``` -------------------------------- ### Include External Configuration Files Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use the `include` directive to import the contents of other Eww configuration files into the current file, helping to organize larger projects. ```lisp (include "./path/to/your/file.yuck") ``` -------------------------------- ### Define a Listening Variable with deflisten Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use `deflisten` to run a script once and continuously read its output line by line. Ideal for real-time updates from processes that emit data, such as log files or status monitors. This is an efficient method when applicable. ```lisp (deflisten foo :initial "whatever" `tail -F /tmp/some_file`) ``` -------------------------------- ### Window Definition with Arguments (Yuck) Source: https://context7.com/elkowar/eww/llms.txt Defines a window that accepts arguments, allowing dynamic geometry based on input. It also passes arguments to child widgets. ```lisp ; Window with arguments (defwindow my_bar [arg1 ?arg2] :monitor 0 :geometry (geometry :x "0%" :y "6px" :width "100%" :height { arg1 == "small" ? "30px" : "40px" } :anchor "top center") :stacking "bg" :windowtype "dock" :reserve (struts :distance "50px" :side "top") (my_widget :arg2 arg2)) ``` -------------------------------- ### Open Eww Windows Source: https://context7.com/elkowar/eww/llms.txt Opens widget windows defined in your configuration. Supports specifying monitor, custom ID, position, size, and toggling. ```bash # Open a window by name ewww open my_bar # Open with specific monitor ewww open my_bar --screen 0 # Open with custom ID (allows multiple instances) ewww open my_bar --screen 0 --id primary ewww open my_bar --screen 1 --id secondary # Open with position and size overrides ewww open my_window --pos 100x50 --size 800x600 --anchor "top left" # Toggle window (open if closed, close if open) ewww open my_bar --toggle # Auto-close after duration ewww open notification --duration 5s # Open with window arguments ewww open my_bar --id primary --arg arg1=some_value --arg arg2=another_value # Open multiple windows at once ewww open-many my_bar:primary my_bar:secondary --arg primary:screen=0 --arg secondary:screen=1 ``` -------------------------------- ### Manage Eww Windows Source: https://context7.com/elkowar/eww/llms.txt Commands for managing open widget windows, including closing specific or all windows, listing definitions, and reloading configuration. ```bash # Close specific windows ewww close my_bar my_dashboard # Close all windows ewww close-all # List available window definitions ewww list-windows # List currently active windows with IDs ewww active-windows # Reload configuration ewww reload # Kill the daemon ewww kill ``` -------------------------------- ### Wayland-Specific Window Options (Yuck) Source: https://context7.com/elkowar/eww/llms.txt Defines a window with Wayland-specific options such as stacking type, exclusivity, focus behavior, and namespace. ```lisp ; Wayland-specific options (defwindow wayland_bar :monitor 0 :geometry (geometry :anchor "top center" :width "100%" :height "30px") :stacking "overlay" ; fg, bg, overlay, bottom :exclusive true ; reserve space automatically :focusable "ondemand" ; none, exclusive, ondemand :namespace "eww-bar" (bar_content)) ``` -------------------------------- ### Define a Listening Variable for File Changes Source: https://context7.com/elkowar/eww/llms.txt Use `deflisten` to continuously monitor the output of a script, such as `tail -F` for file changes. An `:initial` value is provided for the first render. ```lisp ; Listen to file changes (deflisten foo :initial "whatever" `tail -F /tmp/some_file`) ``` -------------------------------- ### Basic Window Definition (Yuck) Source: https://context7.com/elkowar/eww/llms.txt Defines a top-level window with basic geometry, stacking, and window type. Content is provided as a string. ```lisp ; Basic window definition (defwindow example :monitor 0 :geometry (geometry :x "0%" :y "20px" :width "90%" :height "30px" :anchor "top center") :stacking "fg" :reserve (struts :distance "40px" :side "top") :windowtype "dock" :wm-ignore false "example content") ``` -------------------------------- ### Define a Listening Variable for Focused Window Source: https://context7.com/elkowar/eww/llms.txt Monitor the currently focused window using `deflisten` and `xprop`. This can be used to trigger UI changes based on window focus. ```lisp ; Monitor focused window (deflisten focused :initial "" `xprop -spy -root _NET_CURRENT_DESKTOP`) ``` -------------------------------- ### Use a Labeled Container with Child Widgets Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Shows how to use the 'labeled-container' widget and pass a button as its child. The button's 'onclick' event is defined. ```lisp (labeled-container :name "foo" (button :onclick "notify-send hey ho" "click me")) ``` -------------------------------- ### Open Window with Specific Arguments Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Pass values to window arguments using the `--arg` option with the `open` command. Arguments are specified as `name=value`. ```bash eww open my_bar --id primary --arg arg1=some_value --arg arg2=another_value ``` -------------------------------- ### Open Multiple Windows with Specific IDs Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use `--id` with the `open` command to assign unique identifiers to multiple instances of the same window configuration, allowing for distinct management. ```bash eww open my_bar --screen 0 --id primary eww open my_bar --screen 1 --id secondary ``` -------------------------------- ### Clone Eww Repository Source: https://github.com/elkowar/eww/blob/master/docs/src/eww.md Clone the Eww project repository from GitHub to your local machine. ```bash git clone https://github.com/elkowar/eww ``` -------------------------------- ### Define a Listening Variable for Media Player Status Source: https://context7.com/elkowar/eww/llms.txt Monitor the status of a media player using `deflisten` and a command like `playerctl`. The `|| true` ensures the command doesn't fail if no player is running. ```lisp ; Monitor media player (deflisten music :initial "" "playerctl --follow metadata --format '{{ artist }} - {{ title }}' || true") ``` -------------------------------- ### Open Many Windows with IDs Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md When using `open-many`, specify IDs by appending them to the configuration name with a colon (e.g., `config_name:id`). If no ID is given, it defaults to the configuration name. ```bash eww open-many my_config:primary my_config:secondary ``` -------------------------------- ### Apply Global Arguments with Open-Many Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Arguments without a preceding ID in `open-many` are applied to all specified windows. This is useful for setting a uniform configuration across multiple instances. ```bash eww open-many my_bar:primary my_bar:secondary --arg gui_size="small" ``` -------------------------------- ### Special Widgets in Lisp Source: https://context7.com/elkowar/eww/llms.txt Demonstrates advanced Lisp widgets for rendering dynamic content, animated show/hide effects, collapsible sections, transformations, tooltips, and system tray integration. Requires specific configurations for transitions and content. ```lisp (defvar widget_content "(button 'Dynamic')") (literal :content widget_content) ``` ```lisp (revealer :reveal {show_content} :transition "slidedown" ; slideright, slideleft, slideup, slidedown, crossfade, none :duration "300ms" (box "Hidden content")) ``` ```lisp (expander :name "Click to expand" :expanded false (box "Expandable content")) ``` ```lisp (transform :rotate 45 :translate-x "10px" :translate-y "10px" :scale-x "1.5" :scale-y "1.5" :transform-origin-x "50%" :transform-origin-y "50%" (label :text "Transformed")) ``` ```lisp (tooltip (box "This is the tooltip content") (button "Hover for tooltip")) ``` ```lisp (systray :orientation "horizontal" :spacing 5 :icon-size 24 :space-evenly false :prepend-new true) ``` -------------------------------- ### View Eww Logs Source: https://github.com/elkowar/eww/blob/master/docs/src/troubleshooting.md This command displays the current logs for the Eww application, useful for diagnosing issues. ```bash eww logs ``` -------------------------------- ### Open GTK Debugger Source: https://github.com/elkowar/eww/blob/master/docs/src/working_with_gtk.md Run this command in your terminal to open the GTK debugger for Eww. Use it to inspect and debug styling issues. ```bash eww inspector ``` -------------------------------- ### Display Disk Usage using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Access the `EWW_DISK` magic variable to display disk usage percentage for a specific mount point, like '/'. ```lisp ; Disk information (updates every 2s) ; EWW_DISK = {"/" : {"name": "disk", "total": 500000000, "free": 200000000, "used": 300000000, "used_perc": 60}, ...} (label :text "Disk: ${round(EWW_DISK["/"] .used_perc, 0)}%") ``` -------------------------------- ### Use a Widget with Children Source: https://context7.com/elkowar/eww/llms.txt When using a widget that accepts children, place the child elements within the widget's definition. ```lisp ; Using widget with children (labeled-container :name "foo" (button :onclick "notify-send hey ho" "click me")) ``` -------------------------------- ### Debug Eww Widget Structure Source: https://github.com/elkowar/eww/blob/master/docs/src/troubleshooting.md This command provides detailed information about your widget's structure and other debugging data. ```bash eww debug ``` -------------------------------- ### Inspect Eww State Source: https://github.com/elkowar/eww/blob/master/docs/src/troubleshooting.md Use this command to view the current state of all variables managed by Eww. ```bash eww state ``` -------------------------------- ### Define a Labeled Container Widget Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Creates a 'labeled-container' widget that wraps its content in a box with a specific class. It uses the `children` placeholder to render any child widgets passed to it. ```lisp (defwidget labeled-container [name] (box :class "container" name (children))) ``` -------------------------------- ### Eww Debugging and Inspection Source: https://context7.com/elkowar/eww/llms.txt Tools for debugging widget configurations and inspecting state. Includes GTK inspector, state viewing, variable retrieval, and graph generation. ```bash # Open GTK inspector/debugger ewww inspector # Show current variable state ewww state # Show all variables including unused ewww state --all # Get specific variable value ewww get my_variable # Print widget structure ewww debug # Print scope graph in graphviz format ewww graph # View daemon logs ewww logs # Ping daemon to check if running ewww ping ``` -------------------------------- ### Time Formatting with Timezone Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Demonstrates formatting a UNIX timestamp into a human-readable string using a specified format and timezone. Refer to chrono's documentation for format strings and timezones. ```lisp formattime(unix_timestamp, "%Y-%m-%d %H:%M:%S", "America/New_York") ``` -------------------------------- ### Eww Interactive Widgets Source: https://context7.com/elkowar/eww/llms.txt These widgets enable user interaction, allowing for actions like clicks, changes, and input. Configure their behavior using specific event handlers. ```lisp (button :onclick "notify-send 'Clicked!'" :onmiddleclick "xdg-open https://example.com" :onrightclick "eww close my_window" :timeout "200ms" "Click me") ``` ```lisp (eventbox :onclick "echo left" :onrightclick "echo right" :onmiddleclick "echo middle" :onscroll "echo {}" ; {} = "up" or "down" :onhover "echo 'hovered at {} {}'" ; x, y coordinates :onhoverlost "echo 'left'" :cursor "pointer" :ondropped "echo 'dropped: {} {}'" ; uri, type :dragvalue "/path/to/file" :dragtype "file" ; or "text" (label :text "Hover me")) ``` ```lisp (scale :min 0 :max 100 :value {volume} :orientation "horizontal" :flipped false :draw-value true :marks "0,25,50,75,100" :onchange "pamixer --set-volume {}") ``` ```lisp (input :value {search_text} :onchange "eww update search_text={}" :onaccept "search {}" :password false) ``` ```lisp (checkbox :checked {enabled} :onchecked "eww update enabled=true" :onunchecked "eww update enabled=false") ``` ```lisp (combo-box-text :items {["Option 1", "Option 2", "Option 3"]} :onchange "eww update selected={}") ``` ```lisp (color-button :use-alpha true :onchange "eww update color={}") ``` ```lisp (calendar :day {day} :month {month} :year {year} :show-heading true :show-day-names true :onclick "echo 'Selected: {0}/{1}/{2}'") ; day, month, year ``` -------------------------------- ### Define Window with Arguments Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Define arguments within a `defwindow` block, similar to widget arguments. These arguments can be used to customize window properties like geometry. ```lisp (defwindow my_bar [arg1 ?arg2] :geometry (geometry :x "0%" :y "6px" :width "100%" :height { arg1 == "small" ? "30px" : "40px" } :anchor "top center") :stacking "bg" :windowtype "dock" :reserve (struts :distance "50px" :side "top") (my_widget :arg2 arg2)) ``` -------------------------------- ### Environment Variable Access Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Shows how to retrieve the value of an environment variable using the get_env function. ```lisp get_env("MY_VARIABLE") ``` -------------------------------- ### Define a Widget that Accepts Children Source: https://context7.com/elkowar/eww/llms.txt Create widgets that can contain other UI elements by using the `(children)` form. ```lisp ; Widget that accepts children (defwidget labeled-container [name] (box :class "container" name (children))) ``` -------------------------------- ### Open Many Windows with Specific Arguments Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md When using `open-many`, arguments for specific windows are passed after the window names, prefixed with the window ID and a colon (e.g., `id:arg_name=value`). ```bash # Please note that `--arg` option must be given after all the windows names ewww open-many my_bar:primary --arg primary:arg1=some_value --arg primary:arg2=another_value ``` -------------------------------- ### Define a Polling Variable with Initial Value Source: https://context7.com/elkowar/eww/llms.txt Provide an `:initial` value to `defpoll` for faster UI startup before the command first executes. This is useful for variables where a default state is acceptable. ```lisp ; With initial value for faster startup (defpoll volume :interval "1s" :initial "50" "pamixer --get-volume") ``` -------------------------------- ### Byte Formatting (IEC) Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Formats a byte count into a human-readable string using IEC units (KiB, MiB, GiB). Supports negative byte counts and an option for compact output. ```lisp formatbytes(bytes, false, "iec") ``` ```lisp formatbytes(bytes, true, "iec") ``` -------------------------------- ### Byte Formatting (SI) Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Formats a byte count into a human-readable string using SI units (KB, MB, GB). Supports negative byte counts and an option for compact output. ```lisp formatbytes(bytes, false, "si") ``` ```lisp formatbytes(bytes, true, "si") ``` -------------------------------- ### Display Network Download Speed using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Access the `EWW_NET` magic variable to display network download speed for a specific interface, like 'eth0'. ```lisp ; Network information (updates every 2s) ; EWW_NET = {"eth0": {"NET_UP": 1024, "NET_DOWN": 2048}, ...} (label :text "Down: ${EWW_NET.eth0.NET_DOWN} B/s") ``` -------------------------------- ### Basic Expression Language Usage Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Demonstrates embedding expressions within strings and conditional attribute values. Expressions can perform math, string interpolation, and conditional logic. ```lisp (box "Some math: ${12 + foo * 10}" (button :class {button_active ? "active" : "inactive"} :onclick "toggle_thing" {button_active ? "disable" : "enable"})) ``` -------------------------------- ### Define Basic Static Variables Source: https://context7.com/elkowar/eww/llms.txt Use `defvar` to declare static variables that can be updated. This is suitable for configuration values or state that doesn't need frequent polling. ```lisp ; Define basic variables (defvar foo "initial value") (defvar visible false) (defvar counter 0) ; JSON data structures (defvar my_array `["item1", "item2", "item3"]`) (defvar my_object `{"key": "value", "count": 42}`) ; Update via CLI: eww update foo="new value" ``` -------------------------------- ### Generate Widgets from JSON Array using 'for' Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use the `for` element to dynamically generate a list of widgets from a JSON array. This is preferred over `literal` for creating lists of elements. ```lisp (defvar my-json "[1, 2, 3]") ; Then, inside your widget, you can use (box (for entry in my-json (button :onclick "notify-send 'click' 'button ${entry}'" entry))) ``` -------------------------------- ### Manually Reload Eww Source: https://github.com/elkowar/eww/blob/master/docs/src/troubleshooting.md If hot reloading is not functioning, use this command to manually reload the Eww configuration. ```bash eww reload ``` -------------------------------- ### Display RAM Usage using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Utilize the `EWW_RAM` magic variable to show RAM usage percentage. The `round` function formats the output. ```lisp ; RAM information (updates every 2s) ; EWW_RAM = {"total_mem": 16000000, "free_mem": 8000000, "available_mem": 10000000, "used_mem": 6000000, "used_mem_perc": 37.5, ...} (label :text "RAM: ${round(EWW_RAM.used_mem_perc, 0)}%") ``` -------------------------------- ### Common Widget Properties in Lisp Source: https://context7.com/elkowar/eww/llms.txt Illustrates common properties applicable to all Eww widgets, such as class, alignment, expansion, dimensions, visibility, and styling via CSS. These properties control layout, appearance, and interaction. ```lisp (box :class "my-class another-class" :valign "center" ; fill, baseline, center, start, end :halign "center" :vexpand false :hexpand true :width 200 :height 50 :visible {show_widget} :active true ; can be interacted with :tooltip "Hover text" :style "background: red; padding: 10px;" :css "button { color: blue; }") ``` -------------------------------- ### Perform Math Operations in Expressions Source: https://context7.com/elkowar/eww/llms.txt Use standard mathematical operators like addition, division, and modulo within widget expressions to perform calculations. ```lisp ; Math operations (label :text "Result: ${12 + foo * 10}") (label :text "Division: ${100 / 4}") (label :text "Modulo: ${15 % 4}") ``` -------------------------------- ### Use Literal Widget for Dynamic Widget Generation Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md The `literal` widget allows generating entire widget structures dynamically from a string. Use this when the amount or structure of widgets is not known beforehand, but be mindful of performance implications. ```lisp (defvar variable_containing_yuck "(box (button 'foo') (button 'bar'))") ``` ```lisp (literal :content variable_containing_yuck) ``` -------------------------------- ### jq Function Usage Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Illustrates using the jq function to process JSON data with jq-compatible filters. The 'r' flag can be used for raw output. ```lisp jq(json_value, ".field | .subfield") ``` ```lisp jq(json_value, ".field | .subfield", ["r"]) ``` -------------------------------- ### Use Regex Matching in Expressions Source: https://context7.com/elkowar/eww/llms.txt Apply regular expression matching using `=~` to conditionally apply styles or logic based on string patterns. ```lisp ; Regex matching (label :class {workspace.name =~ '^special:.+$' ? "special" : "normal"}) ``` -------------------------------- ### Kill Eww Daemon Source: https://github.com/elkowar/eww/blob/master/docs/src/troubleshooting.md Use this command to stop the Eww daemon. Re-open your window with the `--debug` flag afterwards for additional log output. ```bash eww kill ``` -------------------------------- ### Display CPU Usage using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Access the `EWW_CPU` magic variable to display CPU usage. The `round` function is used for formatting. ```lisp ; CPU information (updates every 2s) ; EWW_CPU = {"cores": [{"core": "cpu0", "freq": 3600, "usage": 25}, ...], "avg": 30} (label :text "CPU: ${round(EWW_CPU.avg, 0)}%") ``` -------------------------------- ### Define a Two-Box Widget with Specific Children Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Defines a 'two-boxes' widget that creates two nested boxes. It uses `children :nth 0` and `children :nth 1` to specifically render the first and second child widgets passed to it, respectively. ```lisp (defwidget two-boxes [] (box (box :class "first" (children :nth 0)) (box :class "second" (children :nth 1)))) ``` -------------------------------- ### Regex Match Operator Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Illustrates the regex match operator (=~). The left-hand side is the regex pattern, and the right-hand side is the string to test against. Supports Rust regex syntax. ```lisp workspace.name =~ '^special:.+$' ``` -------------------------------- ### Eww Layout Widgets Source: https://context7.com/elkowar/eww/llms.txt Use these widgets to structure and organize content within your Eww interface. They control the arrangement and display of child elements. ```lisp (box :orientation "horizontal" :spacing 10 :space-evenly false :halign "center" ; start, center, end, fill :valign "center" (label :text "Item 1") (label :text "Item 2")) ``` ```lisp (centerbox :orientation "horizontal" (label :text "Left") (label :text "Center") (label :text "Right")) ``` ```lisp (scroll :hscroll true :vscroll false (box :orientation "vertical" ; long content here )) ``` ```lisp (overlay (image :path "/path/to/background.png") (label :text "Overlay text")) ``` ```lisp (stack :selected {current_page} :transition "slideright" :same-size true (box "Page 1 content") (box "Page 2 content") (box "Page 3 content")) ``` -------------------------------- ### Set Arguments for Un-IDed Windows in Open-Many Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md If a window in `open-many` does not have an explicit ID, arguments can still be targeted using the window configuration name as a prefix. ```bash eww open-many my_primary_bar --arg my_primary_bar:screen=0 ``` -------------------------------- ### Define a Basic Polling Variable Source: https://context7.com/elkowar/eww/llms.txt Use `defpoll` to create variables that update at a specified interval by executing a shell command. This is ideal for displaying frequently changing data like time or system status. ```lisp ; Basic polling variable (defpoll time :interval "10s" "date '+%H:%M %b %d, %Y'") ``` -------------------------------- ### Display Formatted Unix Timestamp using Magic Variable Source: https://context7.com/elkowar/eww/llms.txt Access the `EWW_TIME` magic variable (Unix timestamp) and format it using the `formattime` function. ```lisp ; Unix timestamp (updates every 1s) ; EWW_TIME = 1699123456 (label :text {formattime(EWW_TIME, "%H:%M:%S")}) ``` -------------------------------- ### Define a Widget with Indexed Children Source: https://context7.com/elkowar/eww/llms.txt Access specific children within a widget using `(children :nth index)`. This is useful for layouts where child order matters. ```lisp ; Widget with indexed children (defwidget two-boxes [] (box (box :class "first" (children :nth 0)) (box :class "second" (children :nth 1)))) ``` -------------------------------- ### Perform Comparison Operations in Expressions Source: https://context7.com/elkowar/eww/llms.txt Use comparison operators (>, ==) within expressions to conditionally render text or apply styles based on variable values. ```lisp ; Comparisons (label :text {value > 50 ? "High" : "Low"}) (label :text {count == 0 ? "Empty" : "Has items"}) ``` -------------------------------- ### Perform Boolean Operations in Expressions Source: https://context7.com/elkowar/eww/llms.txt Combine boolean variables using logical AND (`&&`) and NOT (`!`) operators to control widget visibility or text content. ```lisp ; Boolean operations (box :visible {show_widget && user_logged_in}) (label :text {!hidden ? "Visible" : "Hidden"}) ``` -------------------------------- ### Time Formatting without Timezone Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Shows formatting a UNIX timestamp using the system's local timezone. Uses chrono's documentation for format string details. ```lisp formattime(unix_timestamp, "%Y-%m-%d %H:%M:%S") ``` -------------------------------- ### Use Elvis Operator for Default Values Source: https://context7.com/elkowar/eww/llms.txt The Elvis operator (`?:`) provides a default value if an expression evaluates to empty or null, simplifying conditional rendering. ```lisp ; Elvis operator (default for empty/null) (label :text {title ?: "Unknown"}) ``` -------------------------------- ### Use Safe Navigation Operator for Null Values Source: https://context7.com/elkowar/eww/llms.txt The safe navigation operator (`?.`) prevents errors when accessing properties of potentially null objects or elements in potentially null arrays. ```lisp ; Safe access for potentially null values (label :text {data?.field ?: "N/A"}) (label :text {array?.[0] ?: "Empty"}) ``` -------------------------------- ### Define a Basic Variable with defvar Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use `defvar` for variables that change infrequently or are updated by external scripts or user interactions. Explicitly update values using `eww update`. ```lisp (defvar foo "initial value") ``` -------------------------------- ### Define a Conditional Polling Variable Source: https://context7.com/elkowar/eww/llms.txt Control the execution of a `defpoll` command using `:run-while`. The polling only occurs when the specified condition is true. ```lisp ; Conditional polling with run-while (defvar time-visible false) (defpoll time :interval "1s" :initial "00:00:00" :run-while time-visible `date +%H:%M:%S`) ``` -------------------------------- ### Update Eww Variables Source: https://context7.com/elkowar/eww/llms.txt Dynamically updates variable values in running widgets. Supports single or multiple variables and forcing a poll for defpoll variables. ```bash # Update a single variable ewww update my_variable="new value" # Update multiple variables ewww update volume=75 brightness=50 # Force poll a defpoll variable ewww poll time ``` -------------------------------- ### Access Object Fields in Expressions Source: https://context7.com/elkowar/eww/llms.txt Access properties of JSON objects using dot notation or bracket notation within expressions. ```lisp ; Object field access (label :text {my_object.field}) (label :text {my_object["field"]}) ``` -------------------------------- ### Safe Access Operator Source: https://github.com/elkowar/eww/blob/master/docs/src/expression_language.md Shows the Safe Access operator (?.) for accessing object fields or array elements. It returns null if the left-hand side is null or an empty string, preventing errors. ```lisp object.field?.nested_field ``` ```lisp array[index]?.[nested_index] ``` -------------------------------- ### Eww Built-in Functions for Data Manipulation Source: https://context7.com/elkowar/eww/llms.txt Utilize these functions within expressions for tasks like rounding, math operations, string manipulation, array/object handling, JSON filtering, environment variable access, time formatting, and byte formatting. ```lisp (label :text {round(3.7, 0)}) ``` ```lisp (label :text {floor(3.7)}) ``` ```lisp (label :text {ceil(3.2)}) ``` ```lisp (label :text {min(a, b)}) ``` ```lisp (label :text {max(a, b)}) ``` ```lisp (label :text {powi(2, 8)}) ``` ```lisp (label :text {powf(2.5, 2.0)}) ``` ```lisp (label :text {log(100, 10)}) ``` ```lisp (label :text {sin(degtorad(45))}) ``` ```lisp (label :text {cos(0)}) ``` ```lisp (label :text {radtodeg(3.14159)}) ``` ```lisp (label :text {strlength("hello")}) ``` ```lisp (label :text {substring("hello", 0, 3)}) ``` ```lisp (label :text {replace("hello", "l", "L")}) ``` ```lisp (label :text {matches("test123", "[0-9]+")}) ``` ```lisp (label :text {arraylength(my_array)}) ``` ```lisp (label :text {objectlength(my_object)}) ``` ```lisp (label :text {jq(json_data, ".users[] | .name")}) ``` ```lisp (label :text {jq(json_data, ".value", "r")}) ``` ```lisp (label :text {get_env("HOME")}) ``` ```lisp (label :text {formattime(EWW_TIME, "%Y-%m-%d %H:%M:%S")}) ``` ```lisp (label :text {formattime(EWW_TIME, "%H:%M", "America/New_York")}) ``` ```lisp (label :text {formatbytes(1073741824, false, "iec")}) ``` ```lisp (label :text {formatbytes(1000000000, true, "si")}) ``` -------------------------------- ### Define a Polling Variable with defpoll Source: https://github.com/elkowar/eww/blob/master/docs/src/configuration.md Use `defpoll` to repeatedly run a shell script at a specified interval. Useful for frequently changing data like time, date, or system status. An optional `run-while` condition can control when polling is active. ```lisp (defvar time-visible false) ; for :run-while property of below variable ; when this turns true, the polling starts and ; var gets updated with given interval ``` ```lisp (defpoll time :interval "1s" :initial "initial-value" ; optional, defaults to poll at startup :run-while time-visible ; optional, defaults to 'true' `date +%H:%M:%S`) ``` -------------------------------- ### Define a Complex Polling Variable Source: https://context7.com/elkowar/eww/llms.txt Use `defpoll` with more complex shell commands to fetch and format data from external sources, such as web APIs. ```lisp ; Complex script (defpoll weather :interval "30m" `curl -s "wttr.in/?format=%t"`) ``` -------------------------------- ### Access Array Elements in Expressions Source: https://context7.com/elkowar/eww/llms.txt Access elements of JSON arrays by their index using bracket notation within expressions. ```lisp ; Array index access (label :text {my_array[0]}) (label :text {my_array[index]}) ``` -------------------------------- ### Access Nested JSON Data Source: https://context7.com/elkowar/eww/llms.txt Combine dot and bracket notation to access deeply nested properties within JSON objects and arrays. ```lisp ; Nested access (label :text {data.users[0].name}) (label :text {EWW_DISK["/"] .used_perc}) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.