added function to move windows
This commit is contained in:
parent
d4bb5118da
commit
7f9439b8b0
2 changed files with 21 additions and 4 deletions
|
@ -9,7 +9,7 @@ use workspace_switcher::{prev_or_next_workspace_selector, run_workspace_selector
|
||||||
#[derive(ValueEnum, Debug, Clone)]
|
#[derive(ValueEnum, Debug, Clone)]
|
||||||
enum ProcessType {
|
enum ProcessType {
|
||||||
CalendarBackground,
|
CalendarBackground,
|
||||||
WorkspaceSelector,
|
Workspace,
|
||||||
PrevNextWorkspace,
|
PrevNextWorkspace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,9 +19,15 @@ pub struct CliArgs {
|
||||||
#[arg(index = 1, value_enum)]
|
#[arg(index = 1, value_enum)]
|
||||||
action: Option<ProcessType>,
|
action: Option<ProcessType>,
|
||||||
|
|
||||||
#[arg(index=2, required_if_eq("action", "workspace-selector"))]
|
#[arg(index=2, required_if_eq("action", "workspace"))]
|
||||||
source_workspace: Option<i32>,
|
source_workspace: Option<i32>,
|
||||||
|
|
||||||
|
#[arg(short, long, conflicts_with="switch_workspace", default_value="false")]
|
||||||
|
move_window: bool,
|
||||||
|
|
||||||
|
#[arg(short, long, conflicts_with="move_window", default_value="false")]
|
||||||
|
switch_workspace: bool,
|
||||||
|
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
debug: bool,
|
debug: bool,
|
||||||
}
|
}
|
||||||
|
@ -45,7 +51,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
ProcessType::CalendarBackground => {
|
ProcessType::CalendarBackground => {
|
||||||
run_calendar();
|
run_calendar();
|
||||||
}
|
}
|
||||||
ProcessType::WorkspaceSelector => {
|
ProcessType::Workspace => {
|
||||||
run_workspace_selector(&args);
|
run_workspace_selector(&args);
|
||||||
}
|
}
|
||||||
ProcessType::PrevNextWorkspace => {
|
ProcessType::PrevNextWorkspace => {
|
||||||
|
|
|
@ -68,6 +68,7 @@ fn _get_workspaces_info() -> Vec<WorkspaceInfo> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn prev_or_next_workspace_selector(cli: &CliArgs) {
|
pub fn prev_or_next_workspace_selector(cli: &CliArgs) {
|
||||||
let monitors = get_monitors_info();
|
let monitors = get_monitors_info();
|
||||||
|
|
||||||
|
@ -108,6 +109,12 @@ pub fn prev_or_next_workspace_selector(cli: &CliArgs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_workspace_selector(cli: &CliArgs) {
|
pub fn run_workspace_selector(cli: &CliArgs) {
|
||||||
|
|
||||||
|
if !cli.move_window && !cli.switch_workspace {
|
||||||
|
error!("When action is 'workspace', either `--move-window` or `--switch-window` need to be set");
|
||||||
|
panic!("When action is 'workspace', either `--move-window` or `--switch-window` need to be set");
|
||||||
|
}
|
||||||
|
|
||||||
let output = get_monitors_info();
|
let output = get_monitors_info();
|
||||||
|
|
||||||
debug!("Parsed monitor json: {:#?}", output);
|
debug!("Parsed monitor json: {:#?}", output);
|
||||||
|
@ -145,7 +152,11 @@ pub fn run_workspace_selector(cli: &CliArgs) {
|
||||||
debug!("Target workspace: {}", target_workspace);
|
debug!("Target workspace: {}", target_workspace);
|
||||||
|
|
||||||
debug!("Calling hyprctl and closing");
|
debug!("Calling hyprctl and closing");
|
||||||
|
if cli.switch_workspace {
|
||||||
Command::new("hyprctl").arg("dispatch").arg("workspace").arg(target_workspace.to_string()).output().unwrap();
|
Command::new("hyprctl").arg("dispatch").arg("workspace").arg(target_workspace.to_string()).output().unwrap();
|
||||||
|
} else if cli.move_window {
|
||||||
|
Command::new("hyprctl").arg("dispatch").arg("movetoworkspacesilent").arg(target_workspace.to_string()).output().unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue