Add --toggle to open window
This commit is contained in:
parent
ebf9c7e7ef
commit
a464a849f1
3 changed files with 19 additions and 4 deletions
|
@ -51,6 +51,7 @@ pub enum DaemonCommand {
|
|||
size: Option<Coords>,
|
||||
anchor: Option<AnchorPoint>,
|
||||
monitor: Option<i32>,
|
||||
should_toggle: bool,
|
||||
sender: DaemonResponseSender,
|
||||
},
|
||||
CloseWindow {
|
||||
|
@ -154,8 +155,12 @@ impl App {
|
|||
let result = windows.iter().try_for_each(|w| self.open_window(w, None, None, None, None));
|
||||
respond_with_error(sender, result)?;
|
||||
}
|
||||
DaemonCommand::OpenWindow { window_name, pos, size, anchor, monitor, sender } => {
|
||||
let result = self.open_window(&window_name, pos, size, monitor, anchor);
|
||||
DaemonCommand::OpenWindow { window_name, pos, size, anchor, monitor, should_toggle, sender } => {
|
||||
let result = if should_toggle && self.open_windows.contains_key(&window_name) {
|
||||
self.close_window(&window_name)
|
||||
} else {
|
||||
self.open_window(&window_name, pos, size, monitor, anchor)
|
||||
};
|
||||
respond_with_error(sender, result)?;
|
||||
}
|
||||
DaemonCommand::CloseWindow { window_name, sender } => {
|
||||
|
|
|
@ -89,6 +89,10 @@ pub enum ActionWithServer {
|
|||
/// Sidepoint of the window, formatted like "top right"
|
||||
#[structopt(short, long)]
|
||||
anchor: Option<AnchorPoint>,
|
||||
|
||||
/// If the window is already open, close it instead
|
||||
#[structopt(long = "toggle")]
|
||||
should_toggle: bool,
|
||||
},
|
||||
|
||||
/// Open multiple windows at once.
|
||||
|
@ -168,13 +172,14 @@ impl ActionWithServer {
|
|||
ActionWithServer::OpenMany { windows } => {
|
||||
return with_response_channel(|sender| app::DaemonCommand::OpenMany { windows, sender });
|
||||
}
|
||||
ActionWithServer::OpenWindow { window_name, pos, size, monitor, anchor } => {
|
||||
ActionWithServer::OpenWindow { window_name, pos, size, monitor, anchor, should_toggle } => {
|
||||
return with_response_channel(|sender| app::DaemonCommand::OpenWindow {
|
||||
window_name,
|
||||
pos,
|
||||
size,
|
||||
anchor,
|
||||
monitor,
|
||||
should_toggle,
|
||||
sender,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
(time)))
|
||||
|
||||
(defwidget workspaces []
|
||||
(box :class "workspaces" :orientation "h" :space-evenly true :halign "start"
|
||||
(box :class "workspaces"
|
||||
:orientation "h"
|
||||
:space-evenly true
|
||||
:halign "start"
|
||||
(button :onclick "wmctrl -s 0" 1)
|
||||
(button :onclick "wmctrl -s 1" 2)
|
||||
(button :onclick "wmctrl -s 2" 3)
|
||||
|
@ -37,10 +40,12 @@
|
|||
(scale :min 0 :max 101 :active false :value EWW_RAM))))
|
||||
|
||||
|
||||
|
||||
(defwidget time []
|
||||
(box :class "time"
|
||||
"${hour}:${min} ${month} ${number_day}, ${year_full}"))
|
||||
|
||||
|
||||
(defpoll music :interval "5s" "playerctl metadata --format '{{ artist }} - {{ title }}' || true")
|
||||
(defpoll volume :interval "1s" "scripts/getvol")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue