Add swaybar protocol header
This commit is contained in:
parent
237d95bb52
commit
ff3d53c64d
2 changed files with 28 additions and 2 deletions
|
@ -1,8 +1,12 @@
|
||||||
mod swaybar_object;
|
mod swaybar_object;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!(
|
||||||
|
"{}",
|
||||||
|
serde_json::to_string(&swaybar_object::SwaybarHeader::new())
|
||||||
|
.expect("Should be able to serialize SwaybarHeader")
|
||||||
|
);
|
||||||
|
println!("[");
|
||||||
let mut array = swaybar_object::SwaybarArray::new();
|
let mut array = swaybar_object::SwaybarArray::new();
|
||||||
array.push_object(swaybar_object::SwaybarObject::default());
|
array.push_object(swaybar_object::SwaybarObject::default());
|
||||||
array.push_object(swaybar_object::SwaybarObject::new());
|
array.push_object(swaybar_object::SwaybarObject::new());
|
||||||
|
|
|
@ -3,6 +3,17 @@ use std::fmt::Display;
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct SwaybarHeader {
|
||||||
|
pub version: u32,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub click_events: Option<bool>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub cont_signal: Option<u16>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub stop_signal: Option<u16>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct SwaybarObject {
|
pub struct SwaybarObject {
|
||||||
pub full_text: String,
|
pub full_text: String,
|
||||||
|
@ -45,6 +56,17 @@ pub struct SwaybarArray {
|
||||||
objects: Vec<SwaybarObject>,
|
objects: Vec<SwaybarObject>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SwaybarHeader {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
version: 1,
|
||||||
|
click_events: None,
|
||||||
|
cont_signal: None,
|
||||||
|
stop_signal: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SwaybarObject {
|
impl SwaybarObject {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
Loading…
Reference in a new issue