Skip to content

Times-Z/wayle-plugin-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wayle-plugin-update

First-party Wayle WASM plugin that shows pending system updates in the bar and a grouped dropdown for package details.

What This Plugin Does

  • Polls package manager output and counts pending updates.
  • Displays the pending count in a Wayle bar module.
  • Renders a dropdown grouped by source:
    • pacman updates (via checkupdates)
    • AUR updates (via yay -Qua)
  • Lets you collapse or expand each group directly from the dropdown header rows.
  • Supports manual refresh with middle click.

Runtime Behavior

  • Detection order:
    1. checkupdates
    2. yay
  • If both are available, both groups are shown.
  • If only one exists, only that source is shown.
  • If neither exists, refresh returns an error:
    • no supported package manager found (checkupdates, yay)
  • Default limits and display:
    • max_items = 20 (override with plugin-config.max-items)
    • dropdown title = System updates
    • title alignment = centered (0.5)
    • dropdown max-height style = 50%

Requirements

  • Rust toolchain
  • wasm32-unknown-unknown target
  • At least one package source command available on host:
    • checkupdates
    • or yay

Build

rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown

Artifact:

  • target/wasm32-unknown-unknown/release/wayle_plugin_update.wasm

Install / Deploy

Example deploy command:

cp target/wasm32-unknown-unknown/release/wayle_plugin_update.wasm \
	~/.local/share/wayle/plugins/wayle_plugin_update.wasm

Wayle Configuration

Add a plugin definition in ~/.config/wayle/config.toml and add the module id to bar layout.

[[modules.plugins]]
id = "system-updates"
kind = "wasm"
wasm-path = "/home/you/.local/share/wayle/plugins/wayle_plugin_update.wasm"

# Required for host::run_command calls used by this plugin.
capabilities = ["command.exec"]

# Commands executed by this plugin. Use these as a restrictive allowlist.
command-exec-allowed-prefixes = [
	"command -v",
	"checkupdates",
	"yay -Qua",
]

# Plugin-specific config passed to plugin_init.
plugin-config = { max-items = 40, dropdown-height-percent = 65 }

icon-name = "tb-refresh-dot-symbolic"
interval-ms = 600000
left-click = "dropdown:plugin-system-updates"
middle-click = ""

[[bar.layout]]
monitor = "*"
right = ["plugin-system-updates", "clock"]

Notes About Capabilities

  • Runtime policy precedence for this plugin is:
    1. use capabilities and command-exec-allowed-prefixes from user config when non-empty
    2. otherwise fallback to values declared by plugin manifest()
  • command.exec is required because the plugin executes host commands for detection and update listing.
  • The three prefixes shown cover every command this plugin runs: existence checks (command -v), pacman update list (checkupdates), and AUR update list (yay -Qua).
  • If both config and manifest prefix lists are empty, command execution is blocked.

Security Override In User Config

If you want strict policy control, set both fields explicitly in user config. This overrides manifest fallback.

[[modules.plugins]]
id = "system-updates"
kind = "wasm"
wasm-path = "/home/you/.local/share/wayle/plugins/wayle_plugin_update.wasm"

capabilities = ["command.exec"]
command-exec-allowed-prefixes = [
	"checkupdates",
	"yay -Qua",
	"command -v",
]

You can tighten this list further, but removing required prefixes will disable corresponding update sources.

Plugin-Specific Config

Currently supported keys in plugin-config:

  • max-items (integer): maximum number of package rows shown before the +N more packages indicator is shown.
  • dropdown-height-percent (integer): dropdown max height as a percentage of monitor height.

Behavior:

  • default: 20
  • 0 means unlimited (show all rows)
  • other values are clamped to 1..500

dropdown-height-percent behavior:

  • default: 50
  • valid range: 1..100 (values are clamped)

Interactions

  • Left click: open dropdown (if mapped in config to dropdown:plugin-system-updates).
  • Middle click: trigger immediate refresh.
  • Dropdown section headers (System, AUR): toggle collapsed/expanded state.

Dropdown Rendering Model

  • Empty label row with no description/action is used as separator.
  • Row with label and no description is rendered as section header.
  • Row with label + description is rendered as package entry.

Styling

Plugin-owned styling files:

  • styles/system-updates.scss
  • build.rs compiles SCSS to CSS at build time.

The plugin injects classes via payload style metadata:

  • system-updates-plugin on bar module root
  • system-updates-dropdown on dropdown container

To restyle:

  1. Edit styles/system-updates.scss.
  2. Rebuild plugin.
  3. Redeploy wasm file.

Development Commands

From repository root:

cargo fmt --all
cargo clippy --all-targets --all-features
cargo test
cargo build --release --target wasm32-unknown-unknown

Troubleshooting

Dropdown shows no updates

  • Verify checkupdates or yay is installed and available in PATH.
  • Verify command.exec capability is enabled.
  • If using command-exec-allowed-prefixes, verify required commands are permitted.

Plugin visible but shows errors/tooltips

  • Check Wayle logs for plugin runtime errors.
  • Confirm wasm path points to the latest built artifact.
  • Rebuild and redeploy after changing style or code.

Tests fail on host command output

  • Unit tests should not depend on live host command execution.
  • Seed test state (cached sources) when testing row-action toggle behavior.

Source Overview

  • src/lib.rs: plugin logic, payload building, actions, parsing, tests.
  • styles/system-updates.scss: plugin dropdown and bar styling.
  • build.rs: SCSS compilation into embedded CSS.

About

Wayle plugin for system update

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors