Skip to content

Commit b463f70

Browse files
authored
Merge pull request #609 from multiplex55/remove-linux
Remove linux
2 parents 7c45fad + 8f98f49 commit b463f70

39 files changed

Lines changed: 494 additions & 1052 deletions

Cargo.lock

Lines changed: 326 additions & 395 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,38 +52,26 @@ sysinfo = "0.35"
5252
chrono = "0.4"
5353
screenshots = "0.8.10"
5454
image = { version = "0.24", default-features = false, features = ["png"] }
55-
notify-rust = { version = "4", optional = true }
5655
ipconfig = "0.3"
5756
reqwest = { version = "0.11", default-features = false, features = ["blocking", "rustls-tls"] }
5857
base64 = "0.21"
5958
hex = "0.4"
6059
rand = "0.8"
6160
lipsum = "0.9"
6261
egui_commonmark = "0.15.0"
63-
rfd = { version = "0.15.3", features = ["xdg-portal", "common-controls-v6"] }
62+
rfd = { version = "0.15.3", features = ["common-controls-v6"] }
6463
slab = "0.4.11"
65-
66-
[target.'cfg(unix)'.dependencies]
67-
xcb = "1.6.0"
68-
69-
[target.'cfg(target_os = "windows")'.dependencies]
7064
rdev = { git = "https://github.com/Narsil/rdev", rev = "c14f2dc5c8100a96c5d7e3013de59d6aa0b9eae2" }
7165
rodio = { version = "0.17", default-features = false, features = ["wav"] }
7266

73-
74-
7567
[features]
7668
unstable_grab = []
77-
notify = ["notify-rust"]
7869

7970
[dev-dependencies]
8071
tempfile = "3"
8172
criterion = "0.5"
8273
serial_test = "2"
8374

84-
[target.'cfg(unix)'.dev-dependencies]
85-
xcb = "1.6.0"
86-
8775
[build-dependencies]
8876
embed-resource = "2"
8977

README.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Multi Launcher
22
<img width="480" height="480" alt="Green_MultiLauncher" src="https://github.com/user-attachments/assets/8a68f544-536c-4eb5-8c0a-c5ef43e21c2d" />
33

4-
Multi Launcher is a lightweight application launcher built with Rust and `eframe`.
5-
It supports configurable hotkeys, basic plugin architecture and file indexing to
6-
quickly open applications or files.
4+
Multi Launcher is a lightweight application launcher for Windows built with Rust
5+
and `eframe`. The project targets Windows exclusively. It supports configurable
6+
hotkeys, basic plugin architecture and file indexing to quickly open
7+
applications or files.
78

89

910
## Use Cases
@@ -50,19 +51,12 @@ cargo build --release --features unstable_grab
5051
This feature is defined in `Cargo.toml` and enables the underlying `rdev`
5152
capability used to grab keyboard events.
5253

53-
To show a system notification when a timer or alarm fires, build with the
54-
`notify` feature. This pulls in the optional `notify-rust` dependency:
55-
56-
```
57-
cargo build --release --features notify
58-
```
59-
6054
For debugging, enable **Debug logging** in the settings window. When this
6155
option is active, you can further adjust the verbosity by setting the
6256
`RUST_LOG` environment variable before running the program:
6357

64-
```bash
65-
RUST_LOG=info cargo run --release --features unstable_grab
58+
```powershell
59+
$env:RUST_LOG="info"; cargo run --release --features unstable_grab
6660
```
6761

6862
Enable persistent log files by adding a `log_file` entry to `settings.json`.
@@ -452,8 +446,8 @@ When compiled this way the executable is built with `windows_subsystem = "window
452446

453447
When diagnosing hotkey issues it can be helpful to enable info level logging:
454448

455-
```bash
456-
RUST_LOG=info cargo run
449+
```powershell
450+
$env:RUST_LOG="info"; cargo run
457451
```
458452
## Tips
459453

build.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
#[cfg(target_os = "windows")]
21
fn main() {
32
// no custom macros are passed to the resource compiler
43
embed_resource::compile("Resources/windows.rc", embed_resource::NONE);
54
}
6-
7-
#[cfg(not(target_os = "windows"))]
8-
fn main() {}

src/actions/media.rs

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,14 @@ fn send_key(vk: windows::Win32::UI::Input::KeyboardAndMouse::VIRTUAL_KEY) {
2222
}
2323
}
2424

25-
#[cfg(target_os = "linux")]
26-
fn playerctl(cmd: &str) {
27-
let _ = std::process::Command::new("playerctl").arg(cmd).spawn();
28-
}
29-
3025
#[cfg(target_os = "windows")]
3126
pub fn play() -> anyhow::Result<()> {
3227
use windows::Win32::UI::Input::KeyboardAndMouse::VK_MEDIA_PLAY_PAUSE;
3328
send_key(VK_MEDIA_PLAY_PAUSE);
3429
Ok(())
3530
}
3631

37-
#[cfg(target_os = "linux")]
38-
pub fn play() -> anyhow::Result<()> {
39-
playerctl("play");
40-
Ok(())
41-
}
42-
43-
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
32+
#[cfg(not(target_os = "windows"))]
4433
pub fn play() -> anyhow::Result<()> {
4534
Ok(())
4635
}
@@ -52,13 +41,7 @@ pub fn pause() -> anyhow::Result<()> {
5241
Ok(())
5342
}
5443

55-
#[cfg(target_os = "linux")]
56-
pub fn pause() -> anyhow::Result<()> {
57-
playerctl("pause");
58-
Ok(())
59-
}
60-
61-
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
44+
#[cfg(not(target_os = "windows"))]
6245
pub fn pause() -> anyhow::Result<()> {
6346
Ok(())
6447
}
@@ -70,13 +53,7 @@ pub fn next() -> anyhow::Result<()> {
7053
Ok(())
7154
}
7255

73-
#[cfg(target_os = "linux")]
74-
pub fn next() -> anyhow::Result<()> {
75-
playerctl("next");
76-
Ok(())
77-
}
78-
79-
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
56+
#[cfg(not(target_os = "windows"))]
8057
pub fn next() -> anyhow::Result<()> {
8158
Ok(())
8259
}
@@ -88,13 +65,7 @@ pub fn prev() -> anyhow::Result<()> {
8865
Ok(())
8966
}
9067

91-
#[cfg(target_os = "linux")]
92-
pub fn prev() -> anyhow::Result<()> {
93-
playerctl("previous");
94-
Ok(())
95-
}
96-
97-
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
68+
#[cfg(not(target_os = "windows"))]
9869
pub fn prev() -> anyhow::Result<()> {
9970
Ok(())
10071
}

src/actions/screenshot.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
#[cfg(target_os = "windows")]
21
use chrono::Local;
3-
#[cfg(target_os = "windows")]
42
use std::borrow::Cow;
53
use std::path::PathBuf;
64

7-
#[cfg(target_os = "windows")]
85
use crate::plugins::screenshot::screenshot_dir;
9-
#[cfg(target_os = "windows")]
106
use screenshots::Screen;
11-
#[cfg(target_os = "windows")]
127
use windows::Win32::Foundation::RECT;
13-
#[cfg(target_os = "windows")]
148
use windows::Win32::UI::WindowsAndMessaging::{GetForegroundWindow, GetWindowRect};
159

1610
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -20,7 +14,6 @@ pub enum Mode {
2014
Desktop,
2115
}
2216

23-
#[cfg(target_os = "windows")]
2417
pub fn capture_raw(mode: Mode) -> anyhow::Result<image::RgbaImage> {
2518
match mode {
2619
Mode::Desktop => {
@@ -85,7 +78,6 @@ pub fn capture_raw(mode: Mode) -> anyhow::Result<image::RgbaImage> {
8578
}
8679
}
8780

88-
#[cfg(target_os = "windows")]
8981
pub fn capture(mode: Mode, clipboard: bool) -> anyhow::Result<PathBuf> {
9082
let dir = screenshot_dir();
9183
std::fs::create_dir_all(&dir)?;
@@ -110,7 +102,3 @@ pub fn capture(mode: Mode, clipboard: bool) -> anyhow::Result<PathBuf> {
110102
Ok(path)
111103
}
112104

113-
#[cfg(not(target_os = "windows"))]
114-
pub fn capture(_mode: Mode, _clipboard: bool) -> anyhow::Result<PathBuf> {
115-
anyhow::bail!("screenshot not supported on this platform")
116-
}

src/actions/shell.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
pub fn run(cmd: &str) -> anyhow::Result<()> {
2-
#[cfg(target_os = "windows")]
3-
{
4-
let mut command = {
5-
let mut c = std::process::Command::new("cmd");
6-
c.arg("/C").arg(cmd);
7-
c
8-
};
9-
command.spawn().map(|_| ()).map_err(|e| e.into())
10-
}
11-
#[cfg(not(target_os = "windows"))]
12-
{
13-
let _ = cmd;
14-
Ok(())
15-
}
2+
let mut command = {
3+
let mut c = std::process::Command::new("cmd");
4+
c.arg("/C").arg(cmd);
5+
c
6+
};
7+
command.spawn().map(|_| ()).map_err(|e| e.into())
168
}
179

1810
pub fn add(name: &str, args: &str) -> anyhow::Result<()> {

src/actions/system.rs

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,88 +15,61 @@ pub fn process_kill(pid: u32) {
1515
}
1616
}
1717

18-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
1918
pub fn process_switch(pid: u32) {
20-
#[cfg(target_os = "windows")]
21-
{
22-
super::super::window_manager::activate_process(pid);
23-
}
19+
super::super::window_manager::activate_process(pid);
2420
}
2521

26-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
2722
pub fn window_switch(hwnd: isize) {
28-
#[cfg(target_os = "windows")]
29-
{
30-
use windows::Win32::Foundation::HWND;
31-
super::super::window_manager::force_restore_and_foreground(HWND(hwnd as _));
32-
}
23+
use windows::Win32::Foundation::HWND;
24+
super::super::window_manager::force_restore_and_foreground(HWND(hwnd as _));
3325
}
3426

35-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
3627
pub fn window_close(hwnd: isize) {
37-
#[cfg(target_os = "windows")]
38-
{
39-
use windows::Win32::Foundation::{HWND, LPARAM, WPARAM};
40-
use windows::Win32::UI::WindowsAndMessaging::{PostMessageW, WM_CLOSE};
41-
unsafe {
42-
let _ = PostMessageW(HWND(hwnd as _), WM_CLOSE, WPARAM(0), LPARAM(0));
43-
}
28+
use windows::Win32::Foundation::{HWND, LPARAM, WPARAM};
29+
use windows::Win32::UI::WindowsAndMessaging::{PostMessageW, WM_CLOSE};
30+
unsafe {
31+
let _ = PostMessageW(HWND(hwnd as _), WM_CLOSE, WPARAM(0), LPARAM(0));
4432
}
4533
}
4634

47-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
4835
pub fn set_brightness(v: u32) {
49-
#[cfg(target_os = "windows")]
5036
super::super::launcher::set_display_brightness(v);
5137
}
5238

53-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
5439
pub fn set_volume(v: u32) {
55-
#[cfg(target_os = "windows")]
5640
super::super::launcher::set_system_volume(v);
5741
}
5842

5943
pub fn mute_active_window() {
60-
#[cfg(target_os = "windows")]
6144
super::super::launcher::mute_active_window();
6245
}
6346

64-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
6547
pub fn set_process_volume(pid: u32, level: u32) {
66-
#[cfg(target_os = "windows")]
6748
super::super::launcher::set_process_volume(pid, level);
6849
}
6950

70-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
7151
pub fn toggle_process_mute(pid: u32) {
72-
#[cfg(target_os = "windows")]
7352
super::super::launcher::toggle_process_mute(pid);
7453
}
7554

7655
pub fn recycle_clean() {
77-
#[cfg(target_os = "windows")]
78-
{
79-
// Emptying the recycle bin can take a noticeable amount of time on
80-
// Windows. Running it on the current thread would block the UI and
81-
// cause `launch_action` to return slowly, which in turn makes the
82-
// `recycle_plugin` test fail. Spawn a background thread instead so the
83-
// command returns immediately while the cleanup happens asynchronously.
84-
//
85-
// To keep callers responsive, dispatch a success event right away and
86-
// perform the actual cleanup in the background. Any errors from the
87-
// cleanup are ignored since we have already notified listeners.
88-
std::thread::spawn(|| {
89-
let _ = super::super::launcher::clean_recycle_bin();
90-
});
91-
crate::gui::send_event(crate::gui::WatchEvent::Recycle(Ok(())));
92-
}
56+
// Emptying the recycle bin can take a noticeable amount of time on
57+
// Windows. Running it on the current thread would block the UI and
58+
// cause `launch_action` to return slowly, which in turn makes the
59+
// `recycle_plugin` test fail. Spawn a background thread instead so the
60+
// command returns immediately while the cleanup happens asynchronously.
61+
//
62+
// To keep callers responsive, dispatch a success event right away and
63+
// perform the actual cleanup in the background. Any errors from the
64+
// cleanup are ignored since we have already notified listeners.
65+
std::thread::spawn(|| {
66+
let _ = super::super::launcher::clean_recycle_bin();
67+
});
68+
crate::gui::send_event(crate::gui::WatchEvent::Recycle(Ok(())));
9369
}
9470

95-
#[cfg_attr(not(target_os = "windows"), allow(unused_variables))]
9671
pub fn browser_tab_switch(runtime_id: &[i32]) {
97-
#[cfg(target_os = "windows")]
98-
{
99-
use windows::core::VARIANT;
72+
use windows::core::VARIANT;
10073
use windows::Win32::System::Com::{
10174
CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_INPROC_SERVER,
10275
COINIT_APARTMENTTHREADED,
@@ -298,5 +271,4 @@ pub fn browser_tab_switch(runtime_id: &[i32]) {
298271
}
299272
CoUninitialize();
300273
}
301-
}
302274
}

src/global_hotkey.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
#[cfg(target_os = "windows")]
21
use crate::workspace::is_valid_key_combo;
3-
#[cfg(target_os = "windows")]
42
use log::{error, info, warn};
53
use serde::{Deserialize, Serialize};
64
use std::fmt;
7-
#[cfg(target_os = "windows")]
85
use windows::Win32::UI::Input::KeyboardAndMouse::{
96
RegisterHotKey, HOT_KEY_MODIFIERS, MOD_CONTROL, MOD_ALT, MOD_SHIFT, MOD_WIN,
107
};
118

129
#[derive(Clone, Serialize, Deserialize)]
1310
pub struct Hotkey {
1411
pub key_sequence: String,
15-
#[cfg(target_os = "windows")]
1612
#[serde(skip)]
1713
pub id: Option<i32>,
1814
}
@@ -24,7 +20,6 @@ impl fmt::Display for Hotkey {
2420
}
2521

2622
impl Hotkey {
27-
#[cfg(target_os = "windows")]
2823
pub fn new(key_sequence: &str) -> Result<Self, String> {
2924
if is_valid_key_combo(key_sequence) {
3025
Ok(Self {
@@ -36,7 +31,6 @@ impl Hotkey {
3631
}
3732
}
3833

39-
#[cfg(target_os = "windows")]
4034
pub fn register(&mut self, app: &crate::gui::LauncherApp, id: i32) -> bool {
4135
let mut modifiers: u32 = 0;
4236
let mut vk_code: Option<u32> = None;

0 commit comments

Comments
 (0)