app autostart
This commit is contained in:
@@ -18,17 +18,16 @@
|
||||
<rectangle macro="group_box" id="icon_parent" padding="16" color="#0033aa66" color2="#00000022" gradient="vertical" justify_content="center">
|
||||
|
||||
</rectangle>
|
||||
<div flex_direction="column" gap="8">
|
||||
<label id="label_title" weight="bold" size="32" />
|
||||
<Subtext title="Exec:" label_id="label_exec" />
|
||||
<Subtext title="Args:" label_id="label_args" />
|
||||
<div flex_direction="column" gap="8" min_width="720" max_width="720">
|
||||
<label id="label_title" weight="bold" size="32" overflow="hidden" />
|
||||
<Subtext label_id="label_exec" overflow="hidden" />
|
||||
<Separator />
|
||||
<RadioGroup id="radio_compositor" flex_direction="row" gap="16">
|
||||
<RadioBox text="Native mode" value="Native" checked="1" />
|
||||
<RadioBox text="Compatibility mode" value="Cage" /> <!-- TODO: tooltips -->
|
||||
<RadioBox translation="APP_LAUNCHER.MODE.NATIVE" value="Native" checked="1" />
|
||||
<RadioBox translation="APP_LAUNCHER.MODE.CAGE" value="Cage" /> <!-- TODO: tooltips -->
|
||||
</RadioGroup>
|
||||
<Separator />
|
||||
<label text="Resolution" />
|
||||
<label translation="APP_LAUNCHER.RES_TITLE" />
|
||||
<RadioGroup id="radio_res" flex_direction="row" gap="16">
|
||||
<RadioBox text="1440p" value="Res1440" />
|
||||
<RadioBox text="1080p" value="Res1080" checked="1" />
|
||||
@@ -36,19 +35,30 @@
|
||||
<RadioBox text="480p" value="Res480" />
|
||||
</RadioGroup>
|
||||
<Separator />
|
||||
<label text="Orientation" />
|
||||
<label translation="APP_LAUNCHER.ASPECT_TITLE" />
|
||||
<RadioGroup id="radio_orientation" flex_direction="row" gap="16">
|
||||
<RadioBox text="Wide" value="Wide" tooltip="16:9" checked="1" />
|
||||
<RadioBox text="Semi-Wide" value="SemiWide" tooltip="3:2" />
|
||||
<RadioBox text="Square" value="Square" tooltip="1:1" />
|
||||
<RadioBox text="Semi-Tall" value="SemiTall" tooltip="2:3" />
|
||||
<RadioBox text="Tall" value="Tall" tooltip="9:16" />
|
||||
<RadioBox translation="APP_LAUNCHER.ASPECT.WIDE" value="Wide" tooltip="16:9" checked="1" />
|
||||
<RadioBox translation="APP_LAUNCHER.ASPECT.SEMI_WIDE" value="SemiWide" tooltip="3:2" />
|
||||
<RadioBox translation="APP_LAUNCHER.ASPECT.SQUARE" value="Square" tooltip="1:1" />
|
||||
<RadioBox translation="APP_LAUNCHER.ASPECT.SEMI_TALL" value="SemiTall" tooltip="2:3" />
|
||||
<RadioBox translation="APP_LAUNCHER.ASPECT.TALL" value="Tall" tooltip="9:16" />
|
||||
</RadioGroup>
|
||||
<Button id="btn_launch" align_self="baseline" color="#44ce22FF" padding_top="4" padding_bottom="4" round="8" padding_right="12" min_height="40">
|
||||
<sprite src_builtin="dashboard/play.svg" width="32" height="32" />
|
||||
<label text="Launch" weight="bold" size="17" shadow="#00000099" />
|
||||
</Button>
|
||||
<Separator />
|
||||
<label translation="APP_LAUNCHER.POS_TITLE" />
|
||||
<RadioGroup id="radio_pos" flex_direction="row" gap="16">
|
||||
<RadioBox translation="APP_LAUNCHER.POS.FLOATING" value="Floating" tooltip="APP_LAUNCHER.POS.FLOATING_HELP" />
|
||||
<RadioBox translation="APP_LAUNCHER.POS.ANCHORED" value="Anchored" tooltip="APP_LAUNCHER.POS.ANCHORED_HELP" checked="1" />
|
||||
<RadioBox translation="APP_LAUNCHER.POS.STATIC" value="Static" tooltip="APP_LAUNCHER.POS.STATIC_HELP" />
|
||||
</RadioGroup>
|
||||
<Separator />
|
||||
<div flex_direction="row" justify_content="space_between" gap="16">
|
||||
<CheckBox id="cb_autostart" translation="APP_LAUNCHER.AUTOSTART" />
|
||||
<Button id="btn_launch" align_self="baseline" color="#44ce22FF" padding_top="4" padding_bottom="4" round="8" padding_right="12" min_height="40">
|
||||
<sprite src_builtin="dashboard/play.svg" width="32" height="32" />
|
||||
<label translation="APP_LAUNCHER.LAUNCH" weight="bold" size="17" shadow="#00000099" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</elements>
|
||||
</layout>
|
||||
</layout>
|
||||
|
||||
@@ -83,6 +83,32 @@
|
||||
"SCREENCOPY_HELP": "Slow. Works on: Hyprland, Niri, River, Sway"
|
||||
}
|
||||
},
|
||||
"APP_LAUNCHER": {
|
||||
"MODE": {
|
||||
"NATIVE": "Native mode",
|
||||
"CAGE": "Compatibility mode (Cage)"
|
||||
},
|
||||
"RES_TITLE": "Resolution",
|
||||
"ASPECT_TITLE": "Aspect",
|
||||
"ASPECT": {
|
||||
"WIDE": "Wide",
|
||||
"SEMI_WIDE": "Semi-wide",
|
||||
"SQUARE": "Square",
|
||||
"SEMI_TALL": "Semi-tall",
|
||||
"TALL": "Tall"
|
||||
},
|
||||
"POS_TITLE": "Positioning",
|
||||
"POS": {
|
||||
"FLOATING": "Floating",
|
||||
"ANCHORED": "Anchored",
|
||||
"STATIC": "Static",
|
||||
"FLOATING_HELP": "Moves independently, recenters on show.",
|
||||
"ANCHORED_HELP": "Stays in place relative to center marker.",
|
||||
"STATIC_HELP": "Not part of any set. Does not recenter."
|
||||
},
|
||||
"AUTOSTART": "Run automatically on startup",
|
||||
"LAUNCH": "Launch"
|
||||
},
|
||||
"APPLICATION_LAUNCHER": "Application launcher",
|
||||
"APPLICATION_STARTED": "Application started",
|
||||
"APPLICATIONS": "Applications",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::{collections::HashMap, rc::Rc, str::FromStr};
|
||||
|
||||
use strum::{AsRefStr, EnumString, VariantNames};
|
||||
use wayvr_ipc::packet_client::WvrProcessLaunchParams;
|
||||
use wayvr_ipc::packet_client::{PositionMode, WvrProcessLaunchParams};
|
||||
use wgui::{
|
||||
assets::AssetPath,
|
||||
components::{button::ComponentButton, radio_group::ComponentRadioGroup},
|
||||
components::{button::ComponentButton, checkbox::ComponentCheckbox, radio_group::ComponentRadioGroup},
|
||||
globals::WguiGlobals,
|
||||
i18n::Translation,
|
||||
layout::{Layout, WidgetID},
|
||||
@@ -16,6 +16,13 @@ use wlx_common::{config::GeneralConfig, dash_interface::BoxDashInterface, deskto
|
||||
|
||||
use crate::frontend::{FrontendTask, FrontendTasks, SoundType};
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, EnumString, VariantNames, AsRefStr)]
|
||||
enum PosMode {
|
||||
Floating,
|
||||
Anchored,
|
||||
Static,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, EnumString, VariantNames, AsRefStr)]
|
||||
enum ResMode {
|
||||
Res1440,
|
||||
@@ -43,18 +50,22 @@ enum CompositorMode {
|
||||
enum Task {
|
||||
SetCompositor(CompositorMode),
|
||||
SetRes(ResMode),
|
||||
SetPos(PosMode),
|
||||
SetOrientation(OrientationMode),
|
||||
SetAutoStart(bool),
|
||||
Launch,
|
||||
}
|
||||
|
||||
struct LaunchParams<'a, T> {
|
||||
application: &'a DesktopEntry,
|
||||
compositor_mode: CompositorMode,
|
||||
pos_mode: PosMode,
|
||||
res_mode: ResMode,
|
||||
orientation_mode: OrientationMode,
|
||||
globals: &'a WguiGlobals,
|
||||
frontend_tasks: &'a FrontendTasks,
|
||||
interface: &'a mut BoxDashInterface<T>,
|
||||
auto_start: bool,
|
||||
data: &'a mut T,
|
||||
on_launched: &'a dyn Fn(),
|
||||
}
|
||||
@@ -75,9 +86,12 @@ pub struct View {
|
||||
radio_orientation: Rc<ComponentRadioGroup>,
|
||||
|
||||
compositor_mode: CompositorMode,
|
||||
pos_mode: PosMode,
|
||||
res_mode: ResMode,
|
||||
orientation_mode: OrientationMode,
|
||||
|
||||
auto_start: bool,
|
||||
|
||||
on_launched: Box<dyn Fn()>,
|
||||
}
|
||||
|
||||
@@ -103,22 +117,18 @@ impl View {
|
||||
|
||||
let radio_compositor = state.fetch_component_as::<ComponentRadioGroup>("radio_compositor")?;
|
||||
let radio_res = state.fetch_component_as::<ComponentRadioGroup>("radio_res")?;
|
||||
let radio_pos = state.fetch_component_as::<ComponentRadioGroup>("radio_pos")?;
|
||||
let radio_orientation = state.fetch_component_as::<ComponentRadioGroup>("radio_orientation")?;
|
||||
let cb_autostart = state.fetch_component_as::<ComponentCheckbox>("cb_autostart")?;
|
||||
|
||||
let btn_launch = state.fetch_component_as::<ComponentButton>("btn_launch")?;
|
||||
|
||||
{
|
||||
let mut label_exec = state.fetch_widget_as::<WidgetLabel>(¶ms.layout.state, "label_exec")?;
|
||||
let mut label_args = state.fetch_widget_as::<WidgetLabel>(¶ms.layout.state, "label_args")?;
|
||||
|
||||
label_exec.set_text_simple(
|
||||
&mut params.globals.get(),
|
||||
Translation::from_raw_text_rc(params.entry.exec_path.clone()),
|
||||
);
|
||||
|
||||
label_args.set_text_simple(
|
||||
&mut params.globals.get(),
|
||||
Translation::from_raw_text_rc(params.entry.exec_args.clone()),
|
||||
Translation::from_raw_text_string(format!("{} {}", params.entry.exec_path, params.entry.exec_args)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -159,6 +169,13 @@ impl View {
|
||||
//radio_orientation.set_value(orientation_mode.as_ref())?;
|
||||
//tasks.push(Task::SetOrientation(orientation_mode));
|
||||
|
||||
let pos_mode = PosMode::Floating;
|
||||
// TODO: configurable defaults ?
|
||||
//radio_pos.set_value(pos_mode.as_ref())?;
|
||||
//tasks.push(Task::SetPos(pos_mode));
|
||||
|
||||
let auto_start = false;
|
||||
|
||||
radio_compositor.on_value_changed({
|
||||
let tasks = tasks.clone();
|
||||
Box::new(move |_, ev| {
|
||||
@@ -197,6 +214,25 @@ impl View {
|
||||
})
|
||||
});
|
||||
|
||||
radio_pos.on_value_changed({
|
||||
let tasks = tasks.clone();
|
||||
Box::new(move |_, ev| {
|
||||
if let Some(mode) = ev.value.and_then(|v| {
|
||||
PosMode::from_str(&*v)
|
||||
.inspect_err(|_| {
|
||||
log::error!(
|
||||
"Invalid value for position: '{v}'. Valid values are: {:?}",
|
||||
PosMode::VARIANTS
|
||||
)
|
||||
})
|
||||
.ok()
|
||||
}) {
|
||||
tasks.push(Task::SetPos(mode));
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
|
||||
radio_orientation.on_value_changed({
|
||||
let tasks = tasks.clone();
|
||||
Box::new(move |_, ev| {
|
||||
@@ -216,6 +252,14 @@ impl View {
|
||||
})
|
||||
});
|
||||
|
||||
cb_autostart.on_toggle({
|
||||
let tasks = tasks.clone();
|
||||
Box::new(move |_, ev| {
|
||||
tasks.push(Task::SetAutoStart(ev.checked));
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
|
||||
let mut label_title = state.fetch_widget_as::<WidgetLabel>(¶ms.layout.state, "label_title")?;
|
||||
|
||||
label_title.set_text_simple(
|
||||
@@ -230,8 +274,10 @@ impl View {
|
||||
radio_res,
|
||||
radio_orientation,
|
||||
compositor_mode,
|
||||
pos_mode,
|
||||
res_mode,
|
||||
orientation_mode,
|
||||
auto_start,
|
||||
entry: params.entry,
|
||||
frontend_tasks: params.frontend_tasks.clone(),
|
||||
globals: params.globals.clone(),
|
||||
@@ -249,7 +295,9 @@ impl View {
|
||||
match task {
|
||||
Task::SetCompositor(mode) => self.compositor_mode = mode,
|
||||
Task::SetRes(mode) => self.res_mode = mode,
|
||||
Task::SetPos(mode) => self.pos_mode = mode,
|
||||
Task::SetOrientation(mode) => self.orientation_mode = mode,
|
||||
Task::SetAutoStart(auto_start) => self.auto_start = auto_start,
|
||||
Task::Launch => self.action_launch(interface, data),
|
||||
}
|
||||
}
|
||||
@@ -265,7 +313,9 @@ impl View {
|
||||
globals: &self.globals,
|
||||
compositor_mode: self.compositor_mode,
|
||||
res_mode: self.res_mode,
|
||||
pos_mode: self.pos_mode,
|
||||
orientation_mode: self.orientation_mode,
|
||||
auto_start: self.auto_start,
|
||||
interface,
|
||||
data,
|
||||
on_launched: &self.on_launched,
|
||||
@@ -308,6 +358,12 @@ impl View {
|
||||
CompositorMode::Native => params.application.exec_path.to_string(),
|
||||
};
|
||||
|
||||
let pos_mode = match params.pos_mode {
|
||||
PosMode::Floating => PositionMode::Anchor,
|
||||
PosMode::Anchored => PositionMode::Anchor,
|
||||
PosMode::Static => PositionMode::Static,
|
||||
};
|
||||
|
||||
let mut userdata = HashMap::new();
|
||||
userdata.insert("desktop-entry".to_string(), serde_json::to_string(params.application)?);
|
||||
|
||||
@@ -315,12 +371,14 @@ impl View {
|
||||
|
||||
params.interface.process_launch(
|
||||
params.data,
|
||||
params.auto_start,
|
||||
WvrProcessLaunchParams {
|
||||
env,
|
||||
exec,
|
||||
name: params.application.app_name.to_string(),
|
||||
args,
|
||||
resolution,
|
||||
pos_mode,
|
||||
icon: params.application.icon_path.as_ref().map(|x| x.as_ref().to_string()),
|
||||
userdata,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user