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
12 changes: 11 additions & 1 deletion docs/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ clear_on_hide = false
clear_on_enter = true

# The search engine to use, with the default being google:
search_url = "https://google.com/search?q=%s"
# The URL should have a %s to mark where the search arguments will go
search_url = "https://google.com/search?q=%s"

# As long as the font is installed, you can use it using the exact name (Check in the fontbook app)
font = "Fira Code"

# Get haptic feedback when typing in the search bar
haptic_feedback = true

# Show the tray icon
show_trayicon = true


[theme]

Expand Down
2 changes: 2 additions & 0 deletions src/app/menubar.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! This has the menubar icon logic for the app
use objc2::{MainThreadMarker, sel};
use objc2_app_kit::{NSImage, NSMenu, NSMenuItem, NSStatusBar, NSVariableStatusItemLength};
use objc2_foundation::{NSSize, NSString};

/// This create a new menubar icon for the app
pub fn new_menu_icon(mtm: MainThreadMarker) {
let status_bar = NSStatusBar::systemStatusBar();
let status_item = status_bar.statusItemWithLength(NSVariableStatusItemLength);
Expand Down
6 changes: 4 additions & 2 deletions src/app/tile/elm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ pub fn new(keybind_id: u32, config: &Config) -> (Tile, Task<Message>) {

let paths = default_app_paths();

let mtm = MainThreadMarker::new().unwrap();
new_menu_icon(mtm);
if config.show_trayicon {
let mtm = MainThreadMarker::new().unwrap();
new_menu_icon(mtm);
}

let mut options: Vec<App> = paths
.par_iter()
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Config {
pub placeholder: String,
pub search_url: String,
pub haptic_feedback: bool,
pub show_trayicon: bool,
pub shells: Vec<Shelly>,
}

Expand All @@ -37,6 +38,7 @@ impl Default for Config {
placeholder: String::from("Time to be productive!"),
search_url: "https://google.com/search?q=%s".to_string(),
haptic_feedback: false,
show_trayicon: true,
shells: vec![],
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/haptics.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
//! This is the haptics module for rustcast
//! It is used to perform haptic feedback on the macOS platform
//! For debugging this module, just pray and hope that it works, because even I don't fully understand
//! how it works
#![allow(non_camel_case_types)]

use objc2_core_foundation::{CFNumber, CFNumberType, CFRetained, CFString, CFType};
use once_cell::sync::OnceCell;
use std::ffi::{c_char, c_void};

/// The kinds of haptic patterns that can be performed
#[allow(dead_code)]
#[derive(Copy, Clone, Debug)]
pub enum HapticPattern {
Expand All @@ -16,6 +21,7 @@ unsafe extern "C" {
unsafe fn CFRelease(cf: *mut CFType);
}

/// Convert a pattern to an index
#[inline]
fn pattern_index(pattern: HapticPattern) -> i32 {
match pattern {
Expand Down Expand Up @@ -143,6 +149,8 @@ fn mts_state() -> Option<&'static MtsState> {
MTS.get_or_init(MtsState::open_default_or_all).as_ref()
}

/// Perform a haptic feedback - Just use this function to perform haptic feedback... please don't
/// remake this function unless you're a genius or absolutely have to
pub fn perform_haptic(pattern: HapticPattern) -> bool {
if let Some(state) = mts_state() {
let pat = pattern_index(pattern);
Expand Down