mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 19:34:24 +02:00
commit
6edfe94000
36 changed files with 230 additions and 15 deletions
60
.github/workflows/deploy.yml
vendored
60
.github/workflows/deploy.yml
vendored
|
@ -6,20 +6,13 @@ on:
|
|||
- v[0-9]+.[0-9]+.[0-9]+
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
release:
|
||||
name: 'Create Release'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Install build deps
|
||||
run: ./.github/scripts/ubuntu_setup.sh
|
||||
|
||||
- name: Update CHANGELOG
|
||||
id: changelog
|
||||
uses: Requarks/changelog-action@v1
|
||||
|
@ -41,9 +34,54 @@ jobs:
|
|||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
branch: master
|
||||
commit_message: 'docs: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'
|
||||
commit_message: 'chore: update CHANGELOG.md for ${{ github.ref_name }} [skip ci]'
|
||||
file_pattern: CHANGELOG.md
|
||||
|
||||
- uses: katyo/publish-crates@v1
|
||||
|
||||
publish-crate:
|
||||
name: 'Publish Crate'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Install build deps
|
||||
run: ./.github/scripts/ubuntu_setup.sh
|
||||
|
||||
- name: Publish crate
|
||||
uses: katyo/publish-crates@v1
|
||||
with:
|
||||
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||
|
||||
|
||||
publish-schema:
|
||||
name: 'Publish Schema'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
name: Cache dependencies
|
||||
|
||||
- name: Install build deps
|
||||
run: ./.github/scripts/ubuntu_setup.sh
|
||||
|
||||
- name: Build schema
|
||||
run: cargo build --features schema -- --print-schema > target/schema-${{ github.ref_name }}.json
|
||||
|
||||
- name: Copy file via SSH
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
source: "target/schema-${{ github.ref_name }}.json"
|
||||
target: /storage/Public/github/ironbar
|
||||
strip_components: 1
|
41
.github/workflows/schema.yml
vendored
Normal file
41
.github/workflows/schema.yml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
name: Publish Schema
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUSTFLAGS: '-Dwarnings'
|
||||
|
||||
jobs:
|
||||
publish-schema:
|
||||
name: 'Publish Schema'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
name: Cache dependencies
|
||||
|
||||
- name: Install build deps
|
||||
run: ./.github/scripts/ubuntu_setup.sh
|
||||
|
||||
- name: Build
|
||||
run: cargo build --features schema
|
||||
|
||||
- name: Print schema
|
||||
run: cargo run --features schema -- --print-schema > target/schema.json
|
||||
|
||||
- name: Copy file via SSH
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
source: "target/schema.json"
|
||||
target: /storage/Public/github/ironbar
|
||||
strip_components: 1
|
42
Cargo.lock
generated
42
Cargo.lock
generated
|
@ -755,6 +755,12 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clone"
|
||||
version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
|
@ -1606,6 +1612,7 @@ dependencies = [
|
|||
"notify",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"smithay-client-toolkit",
|
||||
|
@ -2637,6 +2644,30 @@ dependencies = [
|
|||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schemars"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc6e7ed6919cb46507fb01ff1654309219f62b4d603822501b0b80d42f6f21ef"
|
||||
dependencies = [
|
||||
"dyn-clone",
|
||||
"schemars_derive",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schemars_derive"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "185f2b7aa7e02d418e453790dde16890256bbd2bcd04b7dc5348811052b53f49"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.35",
|
||||
"serde_derive_internals",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped-tls"
|
||||
version = "1.0.1"
|
||||
|
@ -2698,6 +2729,17 @@ dependencies = [
|
|||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive_internals"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote 1.0.35",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.117"
|
||||
|
|
|
@ -76,6 +76,8 @@ workspaces = ["futures-lite"]
|
|||
"workspaces+sway" = ["workspaces", "swayipc-async"]
|
||||
"workspaces+hyprland" = ["workspaces", "hyprland"]
|
||||
|
||||
schema = ["dep:schemars"]
|
||||
|
||||
[dependencies]
|
||||
# core
|
||||
gtk = "0.18.1"
|
||||
|
@ -157,3 +159,6 @@ regex = { version = "1.10.4", default-features = false, features = [
|
|||
"std",
|
||||
], optional = true } # music, sys_info
|
||||
zbus = { version = "3.15.2", default-features = false, features = ["tokio"], optional = true } # notifications, upower
|
||||
|
||||
# schema
|
||||
schemars = { version = "0.8.19", optional = true }
|
||||
|
|
|
@ -101,6 +101,9 @@ cargo build --release --no-default-features \
|
|||
| workspaces+all | Enables the `workspaces` module with support for all compositors. |
|
||||
| workspaces+sway | Enables the `workspaces` module with support for Sway. |
|
||||
| workspaces+hyprland | Enables the `workspaces` module with support for Hyprland. |
|
||||
| **Other** | |
|
||||
| schema | Enables JSON schema support and the CLI `--print-schema` flag. |
|
||||
|
||||
|
||||
## Speeding up compiling
|
||||
|
||||
|
|
|
@ -20,11 +20,18 @@ Ironbar supports a range of configuration formats, so you can pick your favourit
|
|||
- `config.json`
|
||||
- `config.toml`
|
||||
- `config.yaml`
|
||||
- `config.corn` (Experimental, includes variable support for re-using blocks.
|
||||
- `config.corn` (Includes variable support for re-using blocks.
|
||||
See [here](https://github.com/jakestanger/corn) for info)
|
||||
|
||||
You can also override the default config path using the `IRONBAR_CONFIG` environment variable.
|
||||
|
||||
A hosted schema is available for the latest Git version ~~and each versioned release~~.
|
||||
JSON and YAML both support schema checking by adding the `$schema` key
|
||||
to the top level of your config.
|
||||
|
||||
- master: `https://f.jstanger.dev/github/ironbar/schema.json`
|
||||
- ~~release: `https://f.jstanger.dev/github/ironbar/schema-v0.16.0.json`~~ *(Not released yet)*
|
||||
|
||||
## 2. Pick your use-case
|
||||
|
||||
Ironbar gives you a few ways to configure the bar to suit your needs.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"$schema": "https://f.jstanger.dev/github/ironbar/schema.json",
|
||||
"anchor_to_edges": true,
|
||||
"position": "bottom",
|
||||
"icon_theme": "Paper",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
$schema: https://f.jstanger.dev/github/ironbar/schema.json
|
||||
anchor_to_edges: true
|
||||
position: bottom
|
||||
icon_theme: Paper
|
||||
|
|
|
@ -9,6 +9,12 @@ pub struct Args {
|
|||
#[command(subcommand)]
|
||||
pub command: Option<Command>,
|
||||
|
||||
/// Prints the config JSON schema to `stdout`
|
||||
/// and exits.
|
||||
#[cfg(feature = "schema")]
|
||||
#[arg(long("print-schema"))]
|
||||
pub print_schema: bool,
|
||||
|
||||
/// `bar_id` argument passed by `swaybar_command`.
|
||||
/// Not used.
|
||||
#[arg(short('b'), hide(true))]
|
||||
|
|
|
@ -16,6 +16,7 @@ use tracing::trace;
|
|||
/// see [here](script).
|
||||
/// For information on styling, please see the [styling guide](styling-guide).
|
||||
#[derive(Debug, Default, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct CommonConfig {
|
||||
/// Sets the unique widget name,
|
||||
/// allowing you to target it in CSS using `#name`.
|
||||
|
@ -160,6 +161,7 @@ pub struct CommonConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum TransitionType {
|
||||
None,
|
||||
Crossfade,
|
||||
|
@ -169,6 +171,7 @@ pub enum TransitionType {
|
|||
|
||||
#[derive(Debug, Default, Deserialize, Clone, Copy)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum ModuleOrientation {
|
||||
#[default]
|
||||
#[serde(alias = "h")]
|
||||
|
|
|
@ -36,11 +36,15 @@ use color_eyre::Result;
|
|||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[cfg(feature = "schema")]
|
||||
use schemars::JsonSchema;
|
||||
|
||||
pub use self::common::{CommonConfig, ModuleOrientation, TransitionType};
|
||||
pub use self::truncate::TruncateMode;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum ModuleConfig {
|
||||
#[cfg(feature = "cairo")]
|
||||
Cairo(Box<CairoModule>),
|
||||
|
@ -117,6 +121,7 @@ impl ModuleConfig {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum MonitorConfig {
|
||||
Single(BarConfig),
|
||||
Multiple(Vec<BarConfig>),
|
||||
|
@ -124,6 +129,7 @@ pub enum MonitorConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Copy, Clone, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub enum BarPosition {
|
||||
Top,
|
||||
Bottom,
|
||||
|
@ -138,6 +144,7 @@ impl Default for BarPosition {
|
|||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Copy, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct MarginConfig {
|
||||
#[serde(default)]
|
||||
pub bottom: i32,
|
||||
|
@ -156,6 +163,7 @@ pub struct MarginConfig {
|
|||
/// depending on your [use-case](#2-pick-your-use-case).
|
||||
///
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct BarConfig {
|
||||
/// A unique identifier for the bar, used for controlling it over IPC.
|
||||
/// If not set, uses a generated integer suffix.
|
||||
|
@ -292,6 +300,7 @@ impl Default for BarConfig {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
#[cfg_attr(feature = "schema", derive(JsonSchema))]
|
||||
pub struct Config {
|
||||
/// A map of [ironvar](ironvar) keys and values
|
||||
/// to initialize Ironbar with on startup.
|
||||
|
|
|
@ -4,6 +4,7 @@ use serde::Deserialize;
|
|||
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum EllipsizeMode {
|
||||
Start,
|
||||
Middle,
|
||||
|
@ -28,6 +29,7 @@ impl From<EllipsizeMode> for GtkEllipsizeMode {
|
|||
///
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum TruncateMode {
|
||||
/// Auto mode lets GTK decide when to ellipsize.
|
||||
///
|
||||
|
|
|
@ -8,6 +8,7 @@ use tokio::sync::mpsc;
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum DynamicBool {
|
||||
/// Either a script or variable, to be determined.
|
||||
Unknown(String),
|
||||
|
|
|
@ -76,6 +76,13 @@ fn main() {
|
|||
fn run_with_args() {
|
||||
let args = cli::Args::parse();
|
||||
|
||||
#[cfg(feature = "schema")]
|
||||
if args.print_schema {
|
||||
let schema = schemars::schema_for!(Config);
|
||||
println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||
return;
|
||||
}
|
||||
|
||||
match args.command {
|
||||
Some(command) => {
|
||||
let rt = create_runtime();
|
||||
|
|
|
@ -18,6 +18,7 @@ use tokio::time::sleep;
|
|||
use tracing::{debug, error};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct CairoModule {
|
||||
/// The path to the Lua script to load.
|
||||
/// This can be absolute, or relative to the working directory.
|
||||
|
|
|
@ -17,6 +17,7 @@ use tokio::sync::{broadcast, mpsc};
|
|||
use tracing::{debug, error};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ClipboardModule {
|
||||
/// The icon to show on the bar widget button.
|
||||
/// Supports [image](images) icons.
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::modules::{
|
|||
use crate::{glib_recv, module_impl, send_async, spawn, try_send};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ClockModule {
|
||||
/// The format string to use for the date/time shown on the bar.
|
||||
/// Pango markup is supported.
|
||||
|
|
|
@ -6,6 +6,7 @@ use gtk::prelude::*;
|
|||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct BoxWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::{build, try_send};
|
|||
use super::{CustomWidget, CustomWidgetContext, ExecEvent, WidgetConfig};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ButtonWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::image::ImageProvider;
|
|||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ImageWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::dynamic_value::dynamic_string;
|
|||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct LabelWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -28,6 +28,7 @@ use tokio::sync::{broadcast, mpsc};
|
|||
use tracing::{debug, error};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct CustomModule {
|
||||
/// Modules and widgets to add to the bar container.
|
||||
///
|
||||
|
@ -45,6 +46,7 @@ pub struct CustomModule {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct WidgetConfig {
|
||||
/// One of a custom module native Ironbar module.
|
||||
#[serde(flatten)]
|
||||
|
@ -57,6 +59,7 @@ pub struct WidgetConfig {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum WidgetOrModule {
|
||||
/// A custom-module specific basic widget
|
||||
Widget(Widget),
|
||||
|
@ -67,6 +70,7 @@ pub enum WidgetOrModule {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum Widget {
|
||||
/// A container to place nested widgets inside.
|
||||
Box(BoxWidget),
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::{build, glib_recv_mpsc, spawn, try_send};
|
|||
use super::{CustomWidget, CustomWidgetContext};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ProgressWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -16,6 +16,7 @@ use crate::{build, glib_recv_mpsc, spawn, try_send};
|
|||
use super::{CustomWidget, CustomWidgetContext, ExecEvent};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct SliderWidget {
|
||||
/// Widget name.
|
||||
///
|
||||
|
|
|
@ -12,6 +12,7 @@ use tokio::sync::mpsc;
|
|||
use tracing::debug;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct FocusedModule {
|
||||
/// Whether to show icon on the bar.
|
||||
///
|
||||
|
|
|
@ -9,6 +9,7 @@ use serde::Deserialize;
|
|||
use tokio::sync::mpsc;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct LabelModule {
|
||||
/// The text to show on the label.
|
||||
/// This is a [Dynamic String](dynamic-values#dynamic-string).
|
||||
|
|
|
@ -19,6 +19,7 @@ use tokio::sync::{broadcast, mpsc};
|
|||
use tracing::{debug, error, trace};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct LauncherModule {
|
||||
/// List of app IDs (or classes) to always show regardless of open state,
|
||||
/// in the order specified.
|
||||
|
|
|
@ -4,6 +4,7 @@ use serde::Deserialize;
|
|||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct Icons {
|
||||
/// Icon to display when playing.
|
||||
///
|
||||
|
@ -71,6 +72,7 @@ impl Default for Icons {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone, Copy)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum PlayerType {
|
||||
Mpd,
|
||||
Mpris,
|
||||
|
@ -83,6 +85,7 @@ impl Default for PlayerType {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct MusicModule {
|
||||
/// Type of player to connect to
|
||||
#[serde(default)]
|
||||
|
|
|
@ -10,6 +10,7 @@ use tokio::sync::mpsc::Receiver;
|
|||
use tracing::error;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct NotificationsModule {
|
||||
/// Whether to show the current notification count.
|
||||
///
|
||||
|
@ -29,6 +30,7 @@ pub struct NotificationsModule {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
struct Icons {
|
||||
/// Icon to show when the panel is closed, with no notifications.
|
||||
///
|
||||
|
|
|
@ -10,6 +10,7 @@ use tokio::sync::mpsc;
|
|||
use tracing::error;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct ScriptModule {
|
||||
/// Path to script to execute.
|
||||
///
|
||||
|
|
|
@ -14,6 +14,7 @@ use tokio::sync::mpsc;
|
|||
use tokio::time::sleep;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct SysInfoModule {
|
||||
/// List of strings including formatting tokens.
|
||||
/// For available tokens, see [below](#formatting-tokens).
|
||||
|
@ -51,6 +52,7 @@ pub struct SysInfoModule {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Copy, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct Intervals {
|
||||
/// The number of seconds between refreshing memory data.
|
||||
///
|
||||
|
@ -91,6 +93,7 @@ pub struct Intervals {
|
|||
|
||||
#[derive(Debug, Deserialize, Copy, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum Interval {
|
||||
All(u64),
|
||||
Individual(Intervals),
|
||||
|
|
|
@ -19,6 +19,7 @@ use tokio::sync::mpsc;
|
|||
use tracing::{debug, error, warn};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct TrayModule {
|
||||
/// Requests that icons from the theme be used over the item-provided item.
|
||||
/// Most items only provide one or the other so this will have no effect in most circumstances.
|
||||
|
@ -38,7 +39,8 @@ pub struct TrayModule {
|
|||
/// **Valid options**: `top_to_bottom`, `bottom_to_top`, `left_to_right`, `right_to_left`
|
||||
/// <br>
|
||||
/// **Default**: `left_to_right` if bar is horizontal, `top_to_bottom` if bar is vertical
|
||||
#[serde(default, deserialize_with = "deserialize_orientation")]
|
||||
#[serde(default, deserialize_with = "deserialize_pack_direction")]
|
||||
#[cfg_attr(feature = "schema", schemars(schema_with = "schema_pack_direction"))]
|
||||
direction: Option<PackDirection>,
|
||||
|
||||
/// See [common options](module-level-options#common-options).
|
||||
|
@ -50,7 +52,7 @@ const fn default_icon_size() -> u32 {
|
|||
16
|
||||
}
|
||||
|
||||
fn deserialize_orientation<'de, D>(deserializer: D) -> Result<Option<PackDirection>, D::Error>
|
||||
fn deserialize_pack_direction<'de, D>(deserializer: D) -> Result<Option<PackDirection>, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
|
@ -61,11 +63,24 @@ where
|
|||
"right_to_left" => Ok(PackDirection::Rtl),
|
||||
"top_to_bottom" => Ok(PackDirection::Ttb),
|
||||
"bottom_to_top" => Ok(PackDirection::Btt),
|
||||
_ => Err(serde::de::Error::custom("invalid value for orientation")),
|
||||
_ => Err(serde::de::Error::custom("invalid value for direction")),
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
|
||||
#[cfg(feature = "schema")]
|
||||
fn schema_pack_direction(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||
use schemars::JsonSchema;
|
||||
let mut schema: schemars::schema::SchemaObject = <String>::json_schema(gen).into();
|
||||
schema.enum_values = Some(vec![
|
||||
"top_to_bottom".into(),
|
||||
"bottom_to_top".into(),
|
||||
"left_to_right".into(),
|
||||
"right_to_left".into(),
|
||||
]);
|
||||
schema.into()
|
||||
}
|
||||
|
||||
impl Module<MenuBar> for TrayModule {
|
||||
type SendMessage = Event;
|
||||
type ReceiveMessage = ActivateRequest;
|
||||
|
|
|
@ -22,6 +22,7 @@ const HOUR: i64 = 60 * 60;
|
|||
const MINUTE: i64 = 60;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct UpowerModule {
|
||||
/// The format string to use for the widget button label.
|
||||
/// For available tokens, see [below](#formatting-tokens).
|
||||
|
|
|
@ -14,6 +14,7 @@ use std::collections::HashMap;
|
|||
use tokio::sync::mpsc;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct VolumeModule {
|
||||
/// The format string to use for the widget button label.
|
||||
/// For available tokens, see [below](#formatting-tokens).
|
||||
|
@ -45,6 +46,7 @@ fn default_format() -> String {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct Icons {
|
||||
/// Icon to show for high volume levels.
|
||||
///
|
||||
|
|
|
@ -15,6 +15,7 @@ use tracing::{debug, trace, warn};
|
|||
|
||||
#[derive(Debug, Deserialize, Clone, Copy, Eq, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum SortOrder {
|
||||
/// Shows workspaces in the order they're added
|
||||
Added,
|
||||
|
@ -31,6 +32,7 @@ impl Default for SortOrder {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum Favorites {
|
||||
ByMonitor(HashMap<String, Vec<String>>),
|
||||
Global(Vec<String>),
|
||||
|
@ -43,6 +45,7 @@ impl Default for Favorites {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct WorkspacesModule {
|
||||
/// Map of actual workspace names to custom names.
|
||||
///
|
||||
|
|
|
@ -14,6 +14,7 @@ use tracing::{debug, error, trace, warn};
|
|||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[serde(untagged)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum ScriptInput {
|
||||
String(String),
|
||||
Struct(Script),
|
||||
|
@ -21,6 +22,7 @@ pub enum ScriptInput {
|
|||
|
||||
#[derive(Debug, Deserialize, Clone, Copy, Eq, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub enum ScriptMode {
|
||||
Poll,
|
||||
Watch,
|
||||
|
@ -75,6 +77,7 @@ impl ScriptMode {
|
|||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
pub struct Script {
|
||||
#[serde(default = "ScriptMode::default")]
|
||||
pub(crate) mode: ScriptMode,
|
||||
|
|
Loading…
Add table
Reference in a new issue