diff --git a/docs/config.toml b/docs/config.toml index fbfedfa..a6258f4 100644 --- a/docs/config.toml +++ b/docs/config.toml @@ -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] diff --git a/src/app/menubar.rs b/src/app/menubar.rs index 814751f..7da0898 100644 --- a/src/app/menubar.rs +++ b/src/app/menubar.rs @@ -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); diff --git a/src/app/tile/elm.rs b/src/app/tile/elm.rs index b9d44c0..716f665 100644 --- a/src/app/tile/elm.rs +++ b/src/app/tile/elm.rs @@ -52,8 +52,10 @@ pub fn new(keybind_id: u32, config: &Config) -> (Tile, Task) { 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 = paths .par_iter() diff --git a/src/config.rs b/src/config.rs index 2a2bcaf..a6f4b43 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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, } @@ -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![], } } diff --git a/src/haptics.rs b/src/haptics.rs index 5aebd0c..50ee2f8 100644 --- a/src/haptics.rs +++ b/src/haptics.rs @@ -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 { @@ -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 { @@ -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);