Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/actions/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use chrono::Local;
use std::borrow::Cow;
use std::path::PathBuf;

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Mode {
Window,
Region,
Expand Down
17 changes: 17 additions & 0 deletions src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ enum ActionKind<'a> {
BrightnessSet(u32),
VolumeSet(u32),
VolumeMuteActive,
Screenshot { mode: crate::actions::screenshot::Mode, clip: bool },
MediaPlay,
MediaPause,
MediaNext,
Expand Down Expand Up @@ -390,6 +391,18 @@ fn parse_action_kind(action: &Action) -> ActionKind<'_> {
if s == "volume:mute_active" {
return ActionKind::VolumeMuteActive;
}
if let Some(mode) = s.strip_prefix("screenshot:") {
use crate::actions::screenshot::Mode as ScreenshotMode;
return match mode {
"window" => ActionKind::Screenshot { mode: ScreenshotMode::Window, clip: false },
"region" => ActionKind::Screenshot { mode: ScreenshotMode::Region, clip: false },
"desktop" => ActionKind::Screenshot { mode: ScreenshotMode::Desktop, clip: false },
"window_clip" => ActionKind::Screenshot { mode: ScreenshotMode::Window, clip: true },
"region_clip" => ActionKind::Screenshot { mode: ScreenshotMode::Region, clip: true },
"desktop_clip" => ActionKind::Screenshot { mode: ScreenshotMode::Desktop, clip: true },
_ => ActionKind::ExecPath { path: s, args: action.args.as_deref() },
};
}
if s == "media:play" {
return ActionKind::MediaPlay;
}
Expand Down Expand Up @@ -515,6 +528,10 @@ pub fn launch_action(action: &Action) -> anyhow::Result<()> {
system::mute_active_window();
Ok(())
}
ActionKind::Screenshot { mode, clip } => {
crate::actions::screenshot::capture(mode, clip)?;
Ok(())
}
ActionKind::MediaPlay => {
crate::actions::media::play()?;
Ok(())
Expand Down