├── .gitignore ├── rustfmt.toml ├── src ├── launcher │ ├── util │ │ ├── mod.rs │ │ ├── display.rs │ │ ├── dirs.rs │ │ ├── icon.rs │ │ ├── query_history.rs │ │ ├── app.rs │ │ ├── recent.rs │ │ ├── theme.rs │ │ └── config.rs │ ├── mod.rs │ ├── navigation.rs │ ├── result.rs │ └── window.rs ├── lib.rs ├── dlauncher-toggle.rs ├── extension │ ├── query.rs │ ├── mod.rs │ ├── response.rs │ └── config.rs ├── entry │ ├── script_entry.rs │ ├── app_entry.rs │ ├── extension_entry.rs │ └── mod.rs ├── fuzzy │ ├── util.rs │ └── mod.rs ├── dlauncher.rs ├── script │ └── mod.rs └── util.rs ├── data ├── themes │ └── light │ │ ├── theme-gtk-3.20.css │ │ ├── manifest.json │ │ ├── reset.css │ │ └── theme.css └── ui │ ├── DlauncherWindow.ui │ └── result.ui ├── Makefile ├── Cargo.toml ├── README.md ├── EXTENSIONS.md ├── Cargo.lock └── LICENCE /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | perf.data 3 | perf.data.old 4 | recents.dlauncher 5 | .idea 6 | .vscode -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | imports_granularity = "Crate" 2 | tab_spaces = 2 3 | trailing_comma = "Vertical" -------------------------------------------------------------------------------- /src/launcher/util/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod app; 2 | pub mod config; 3 | pub mod dirs; 4 | pub mod icon; 5 | pub mod query_history; 6 | pub mod recent; 7 | pub mod theme; 8 | pub mod display; 9 | -------------------------------------------------------------------------------- /data/themes/light/theme-gtk-3.20.css: -------------------------------------------------------------------------------- 1 | @import url("theme.css"); 2 | 3 | .input { 4 | caret-color: @caret_color; 5 | } 6 | .selected.item-box { 7 | /* workaround for a bug in GTK+ < 3.20 */ 8 | border: none; 9 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | run_debug: 2 | RUST_LOG=debug cargo run 3 | 4 | run: 5 | ./target/release/dlauncher 6 | 7 | run_debug_log: 8 | RUST_LOG=debug ./target/release/dlauncher 9 | 10 | build: 11 | cargo build --release 12 | 13 | docs: 14 | cargo doc --no-deps -------------------------------------------------------------------------------- /src/launcher/mod.rs: -------------------------------------------------------------------------------- 1 | // Navigation helper 2 | pub mod navigation; 3 | // Result UI element 4 | pub mod result; 5 | // Launcher utilties 6 | pub mod util; 7 | // Launcher UI and main logic as well as many public functions useful for extensions. 8 | pub mod window; 9 | -------------------------------------------------------------------------------- /data/themes/light/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": "1", 3 | "name": "light", 4 | "display_name": "Light", 5 | "css_file": "theme.css", 6 | "css_file_gtk_3.20+": "theme-gtk-3.20.css", 7 | "matched_text_hl_colors": { 8 | "when_selected": "#2c74cc", 9 | "when_not_selected": "#2c74cc" 10 | } 11 | } -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | 3 | /// Entry UI Elements 4 | pub mod entry; 5 | 6 | pub mod extension; 7 | /// This module encompasses all the main logic of dlauncher. 8 | pub mod launcher; 9 | /// Utility methods for extensions and the launcher itself. 10 | pub mod util; 11 | 12 | /// Fuzzy Search utilities 13 | pub mod fuzzy; 14 | 15 | pub mod script; 16 | -------------------------------------------------------------------------------- /src/dlauncher-toggle.rs: -------------------------------------------------------------------------------- 1 | use std::time::Duration; 2 | 3 | use dbus::blocking::Connection; 4 | 5 | fn main() -> Result<(), Box> { 6 | let conn = Connection::new_session()?; 7 | let proxy = conn.with_proxy("com.dlauncher.server", "/open", Duration::from_millis(5000)); 8 | proxy.method_call("com.dlauncher.server", "OpenWindow", ())?; 9 | 10 | Ok(()) 11 | } 12 | -------------------------------------------------------------------------------- /src/launcher/util/display.rs: -------------------------------------------------------------------------------- 1 | use gtk::gdk::{Display, Monitor, prelude::*}; 2 | use gtk::gio::Settings; 3 | 4 | pub fn monitor() -> Monitor { 5 | let display = Display::default().unwrap(); 6 | if let Some(monitor) = display.primary_monitor() { 7 | monitor 8 | } else if let Some(monitor) = display.monitor(0) { 9 | monitor 10 | } else { 11 | let seat = display.default_seat().unwrap(); 12 | let (_, x, y) = seat.pointer().unwrap().position(); 13 | 14 | if let Some(monitor) = display.monitor_at_point(x, y) { 15 | monitor 16 | } else { 17 | panic!("Couldn't get monitor through various methods...") 18 | } 19 | } 20 | } 21 | 22 | pub fn scaling_factor() -> f32 { 23 | let monitor_scaling = monitor().scale_factor(); 24 | let text_scaling = Settings::new("org.gnome.desktop.interface"); 25 | let text_scaling = text_scaling.double("text-scaling-factor"); 26 | 27 | (monitor_scaling as f64 * text_scaling) as f32 28 | } -------------------------------------------------------------------------------- /src/extension/query.rs: -------------------------------------------------------------------------------- 1 | /// Simple struct that is supposed to serve as a utility for inputs. 2 | #[derive(Debug, Clone)] 3 | pub struct Query(String, String); 4 | 5 | impl Query { 6 | /// Parses a string into Query 7 | pub fn from_str(query: &str) -> Query { 8 | let query_parts = query.split_once(' ').unwrap_or((query, "")); 9 | Query(query_parts.0.to_string(), query_parts.1.to_string()) 10 | } 11 | 12 | /// Get the prefix of a query, for example 13 | /// "something test", the prefix is "something" 14 | pub fn prefix(&self) -> &str { 15 | &self.0 16 | } 17 | 18 | /// Get the rest of the query (arguments, etc.) 19 | /// 20 | /// For example, "something test", the query is "test" 21 | pub fn query(&self) -> &str { 22 | &self.1 23 | } 24 | 25 | /// If you do not want to listen to a prefix then you can just read the entire query 26 | pub fn all(&self) -> String { 27 | format!("{} {}", self.0, self.1) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/entry/script_entry.rs: -------------------------------------------------------------------------------- 1 | use gtk::{ 2 | gdk_pixbuf::{Pixbuf, PixbufLoader}, 3 | prelude::*, 4 | }; 5 | 6 | use crate::{ 7 | launcher::util::icon::load_icon, 8 | script::{Script, ScriptIcon}, 9 | }; 10 | 11 | #[derive(Debug, Clone)] 12 | pub struct ScriptEntry { 13 | script: Script, 14 | } 15 | 16 | impl ScriptEntry { 17 | pub fn new(script: Script) -> Self { 18 | Self { script } 19 | } 20 | 21 | pub fn name(&self) -> &str { 22 | &self.script.meta.name 23 | } 24 | 25 | pub fn desc(&self) -> &str { 26 | &self.script.meta.desc 27 | } 28 | 29 | pub fn run(&self) -> () { 30 | self.script.run(); 31 | } 32 | 33 | pub fn icon(&self) -> Pixbuf { 34 | match &self.script.meta.icon { 35 | ScriptIcon::Themed(value) => load_icon(&value, 40), 36 | ScriptIcon::Svg(value) => { 37 | let loader = PixbufLoader::new(); 38 | loader.write(value.as_bytes()).unwrap(); 39 | loader.close().unwrap(); 40 | 41 | loader.pixbuf().unwrap() 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dlauncher" 3 | version = "0.1.2" 4 | edition = "2021" 5 | license = "GPL-3.0" 6 | description = "An application launcher for Linux that is based on Ulauncher" 7 | homepage = "https://github.com/diced/dlauncher" 8 | repository = "https://github.com/diced/dlauncher" 9 | documentation = "https://docs.rs/dlauncher" 10 | default-run = "dlauncher" 11 | 12 | [[bin]] 13 | name = "dlauncher" 14 | path = "src/dlauncher.rs" 15 | 16 | [[bin]] 17 | name = "dlauncher-toggle" 18 | path = "src/dlauncher-toggle.rs" 19 | 20 | [dependencies] 21 | gtk = { version = "0.15.5", features = ["v3_22"] } 22 | dbus = "0.9.5" 23 | dbus-crossroads = "0.5.0" 24 | regex = "1.5.5" 25 | libc = "0.2.1" 26 | serde = { version = "1.0.136", features = ["derive"] } 27 | toml = "0.5.9" 28 | serde_json = "1.0.79" 29 | libloading = "0.7.3" 30 | dashmap = { version = "5.3.3", features = ["serde"] } 31 | log = "0.4.17" 32 | env_logger = "0.9.0" 33 | shell-words = "1.1.0" 34 | 35 | [profile.release] 36 | strip = true 37 | codegen-units = 1 38 | incremental = true -------------------------------------------------------------------------------- /src/launcher/util/dirs.rs: -------------------------------------------------------------------------------- 1 | use std::{env, path::PathBuf}; 2 | 3 | pub struct Dirs { 4 | pub home: PathBuf, 5 | pub config: PathBuf, 6 | pub extensions: PathBuf, 7 | pub extension_configs: PathBuf, 8 | pub themes: PathBuf, 9 | } 10 | 11 | impl Dirs { 12 | pub fn new() -> Dirs { 13 | let home = env::var("HOME").expect("homeless"); 14 | let home = PathBuf::from(home); 15 | let config = home.join(".config/dlauncher"); 16 | let extensions = config.join("extensions"); 17 | let extension_configs = extensions.join("extension_config"); 18 | let themes = config.join("themes"); 19 | 20 | Dirs { 21 | home, 22 | config, 23 | extensions, 24 | extension_configs, 25 | themes, 26 | } 27 | } 28 | 29 | pub fn create_dirs(&self) { 30 | let dirs = [ 31 | &self.config, 32 | &self.extensions, 33 | &self.extension_configs, 34 | &self.themes, 35 | ]; 36 | 37 | for dir in dirs.iter() { 38 | if !dir.exists() { 39 | std::fs::create_dir_all(dir).expect("failed to create dirs"); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/launcher/util/icon.rs: -------------------------------------------------------------------------------- 1 | use gtk::{gdk_pixbuf::Pixbuf, prelude::*, IconLookupFlags, IconTheme}; 2 | 3 | /// Get a themed icon's specific path on the filesystem. 4 | pub fn get_icon_path(icon: &str, size: i32) -> String { 5 | let icon_theme = IconTheme::default().unwrap(); 6 | 7 | if icon.starts_with('/') { 8 | icon.to_string() 9 | } else if let Some(themed_icon) = icon_theme.lookup_icon(icon, size, IconLookupFlags::FORCE_SIZE) 10 | { 11 | themed_icon 12 | .filename() 13 | .unwrap() 14 | .to_string_lossy() 15 | .to_string() 16 | } else { 17 | icon_theme 18 | .lookup_icon( 19 | "dialog-question-symbolic", 20 | size, 21 | IconLookupFlags::FORCE_SIZE, 22 | ) 23 | .unwrap() 24 | .filename() 25 | .unwrap() 26 | .to_string_lossy() 27 | .to_string() 28 | } 29 | } 30 | 31 | /// Load a themed icon with a specified size. 32 | pub fn load_icon(icon: &str, size: i32) -> Pixbuf { 33 | let icon_path = get_icon_path(icon, size); 34 | 35 | if let Ok(pixbuf) = Pixbuf::from_file_at_size(&icon_path, size, size) { 36 | pixbuf 37 | } else { 38 | default_pixbuf(size) 39 | } 40 | } 41 | 42 | pub fn default_pixbuf(size: i32) -> Pixbuf { 43 | let icon_path = get_icon_path("dialog-question-symbolic", size); 44 | 45 | Pixbuf::from_file_at_size(&icon_path, size, size).unwrap() 46 | } 47 | -------------------------------------------------------------------------------- /src/launcher/util/query_history.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{read, write}, 3 | path::PathBuf, 4 | }; 5 | 6 | use dashmap::DashMap; 7 | use log::debug; 8 | 9 | use crate::launcher::util::config::Config; 10 | 11 | #[derive(Debug, Clone)] 12 | pub struct QueryHistory { 13 | file: PathBuf, 14 | map: DashMap, 15 | } 16 | 17 | impl QueryHistory { 18 | pub fn new(config: Config) -> Self { 19 | let file = config.dir().join("query_history.json"); 20 | let map = if file.exists() { 21 | debug!("Loading query_history located at: {}", file.display()); 22 | let contents = read(&file).unwrap(); 23 | serde_json::from_slice(&contents).unwrap() 24 | } else { 25 | debug!( 26 | "Creating an empty query_history located at: {}", 27 | file.display() 28 | ); 29 | let map = DashMap::new(); 30 | write(&file, serde_json::to_vec(&map).unwrap()).unwrap(); 31 | 32 | map 33 | }; 34 | 35 | QueryHistory { map, file } 36 | } 37 | 38 | pub fn find(&self, query: impl Into) -> Option { 39 | self.map.get(&query.into()).map(|t| t.value().clone()) 40 | } 41 | 42 | pub fn save_query( 43 | &self, 44 | query: impl Into, 45 | item_name: impl Into, 46 | ) -> Option { 47 | let query = query.into(); 48 | let item_name = item_name.into(); 49 | 50 | let value = self.map.insert(query.clone(), item_name); 51 | self.save(); 52 | 53 | value 54 | } 55 | 56 | pub fn save(&self) { 57 | write(&self.file, serde_json::to_vec_pretty(&self.map).unwrap()).unwrap(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/entry/app_entry.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | use gtk::gdk_pixbuf::Pixbuf; 4 | use log::debug; 5 | 6 | use crate::{ 7 | launcher::{ 8 | util::{icon::default_pixbuf, recent::Recent}, 9 | window::Window, 10 | }, 11 | util::launch_detached, 12 | }; 13 | 14 | #[derive(Debug, Clone)] 15 | pub struct AppEntry { 16 | pub name: String, 17 | pub description: String, 18 | pub file: PathBuf, 19 | pub icon: Option, 20 | pub exec: Vec, 21 | pub terminal: bool, 22 | } 23 | 24 | impl AppEntry { 25 | pub fn execute(&self, window: Window) { 26 | let spawn_args = if self.terminal && window.config.launcher.terminal_command.as_ref().is_some() { 27 | let cmd = window.config.launcher.terminal_command.as_ref().unwrap(); 28 | let full = shell_words::join(&self.exec); 29 | let cmd = cmd.replace("{}", &full); 30 | 31 | shell_words::split(&cmd).unwrap() 32 | } else { 33 | self.exec.clone() 34 | }; 35 | 36 | debug!("Attempting to launch {:?}", spawn_args); 37 | 38 | launch_detached(spawn_args, vec![]); 39 | 40 | let mut recents = window.state.recents.lock().unwrap(); 41 | let recent = recents.iter_mut().find(|r| r.file == self.file); 42 | if let Some(recent) = recent { 43 | recent.num += 1; 44 | } else { 45 | recents.push(Recent { 46 | num: 1, 47 | file: self.file.clone(), 48 | }); 49 | } 50 | 51 | recents.sort_by(|a, b| b.num.cmp(&a.num)); 52 | Recent::recents_to_file(recents.to_vec(), &window.config.recents()); 53 | } 54 | 55 | pub fn icon(&self) -> Pixbuf { 56 | match &self.icon { 57 | Some(icon) => icon.clone(), 58 | None => default_pixbuf(40), 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/launcher/util/app.rs: -------------------------------------------------------------------------------- 1 | use std::path::PathBuf; 2 | 3 | use gtk::{ 4 | gio::{AppInfo, DesktopAppInfo}, 5 | glib::GString, 6 | prelude::*, 7 | }; 8 | use log::debug; 9 | use regex::Regex; 10 | 11 | use crate::{entry::app_entry::AppEntry, launcher::util::icon::load_icon}; 12 | 13 | pub struct App; 14 | 15 | impl App { 16 | pub fn all() -> Vec { 17 | debug!("Reading apps"); 18 | let mut results = Vec::new(); 19 | 20 | let re = Regex::new(r"%[uUfFdDnNickvm]").unwrap(); 21 | 22 | for a in AppInfo::all() { 23 | if !a.should_show() { 24 | continue; 25 | } 26 | 27 | if let Some(exec) = a.commandline() { 28 | let icon = if a.icon().is_none() { 29 | None 30 | } else { 31 | let st = gtk::prelude::IconExt::to_string(&a.icon().unwrap()) 32 | .unwrap() 33 | .to_string(); 34 | 35 | Some(load_icon(&st, 40)) 36 | }; 37 | 38 | if let Some(file) = a.id() { 39 | let exec: Vec = 40 | shell_words::split(&*re.replace(&*exec.display().to_string(), "")).unwrap(); 41 | 42 | let terminal = if let Some(desktop) = DesktopAppInfo::new(&a.id().unwrap()) { 43 | desktop.boolean("Terminal") 44 | } else { 45 | false 46 | }; 47 | 48 | results.push(AppEntry { 49 | name: a.display_name().to_string(), 50 | description: a 51 | .description() 52 | .unwrap_or_else(|| GString::from("")) 53 | .to_string(), 54 | file: PathBuf::from(file.to_string()), 55 | icon, 56 | exec, 57 | terminal, 58 | }) 59 | } 60 | } 61 | } 62 | 63 | debug!("Read {} apps", results.len()); 64 | 65 | results 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/launcher/util/recent.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{write, File}, 3 | io::{BufRead, BufReader}, 4 | path::PathBuf, 5 | sync::{Arc, Mutex}, 6 | }; 7 | 8 | use log::debug; 9 | 10 | use crate::{ 11 | entry::{app_entry::AppEntry, ResultEntry}, 12 | launcher::{result::ResultWidget, window::Window}, 13 | util::no_match, 14 | }; 15 | 16 | #[derive(Debug, Clone)] 17 | pub struct Recent { 18 | pub num: u32, 19 | pub file: PathBuf, 20 | } 21 | 22 | impl Recent { 23 | pub fn all(path: &PathBuf) -> Vec { 24 | debug!("Fetching recent apps"); 25 | let file = File::open(&path); 26 | let mut recents: Vec = vec![]; 27 | if let Ok(file) = file { 28 | let lines = BufReader::new(&file).lines(); 29 | for line in lines { 30 | let line = line.unwrap(); 31 | let line = line.trim().split_once(' ').unwrap(); 32 | 33 | recents.push(Recent { 34 | num: line.0.parse::().expect("Failed to parse number"), 35 | file: PathBuf::from(line.1), 36 | }); 37 | } 38 | file.sync_all().unwrap(); 39 | } else { 40 | write(&path, "").unwrap(); 41 | } 42 | debug!("Recent apps refreshed"); 43 | 44 | recents.sort_by(|a, b| b.num.cmp(&a.num)); 45 | 46 | recents 47 | } 48 | 49 | pub fn recents_to_file(recents: Vec, path: &PathBuf) { 50 | let st = recents 51 | .iter() 52 | .map(|r| format!("{} {}", r.num, r.file.to_str().unwrap())) 53 | .collect::>() 54 | .join("\n"); 55 | write(&path, st).unwrap(); 56 | } 57 | 58 | pub fn to_result(&self, window: Window, apps: Arc>>) -> Option { 59 | let apps = apps.lock().unwrap(); 60 | let app = apps.iter().find(|app| app.file == self.file); 61 | app.map(|app| ResultWidget::new(ResultEntry::App(app.clone()), window, no_match())) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/fuzzy/util.rs: -------------------------------------------------------------------------------- 1 | // The slice_utf8, find_longest_match are from https://github.com/logannc/fuzzywuzzy-rs/blob/master/src/utils.rs with some modifications 2 | // I did not want to import the whole crate for just one function. 3 | 4 | pub fn slice_utf8(string: &str, low: usize, high: usize) -> &str { 5 | let char_count = string.chars().count(); 6 | debug_assert!(!(low > high)); 7 | debug_assert!(!(high > char_count)); 8 | if low == high { 9 | return ""; 10 | } 11 | let mut indices = string 12 | .char_indices() 13 | .enumerate() 14 | .map(|(char_offset, (byte_offset, _))| (byte_offset, char_offset)); 15 | let low_index = indices 16 | .find(|(_, co)| *co == low) 17 | .expect("Beginning of slice not found.") 18 | .0; 19 | let mut indices = indices.skip_while(|(_, co)| *co != high); 20 | #[allow(clippy::or_fun_call)] 21 | let high_index = indices.next().map(|(bo, _)| bo).unwrap_or(string.len()); 22 | &string[low_index..high_index] 23 | } 24 | 25 | pub(crate) fn find_longest_match<'a>( 26 | shorter: &'a str, 27 | longer: &'a str, 28 | low1: usize, 29 | high1: usize, 30 | low2: usize, 31 | high2: usize, 32 | ) -> (usize, usize, usize) { 33 | let longsub = slice_utf8(longer, low2, high2); 34 | let mut byte_to_char_map = vec![0; longsub.len()]; 35 | longsub 36 | .char_indices() 37 | .enumerate() 38 | .for_each(|(char_offset, (byte_offset, _))| { 39 | byte_to_char_map[byte_offset] = char_offset; 40 | }); 41 | let slen = high1 - low1; 42 | for size in (1..slen + 1).rev() { 43 | for start in 0..slen - size + 1 { 44 | let substr = slice_utf8(&shorter, low1 + start, low1 + start + size); 45 | if let Some((startb, matchstr)) = longsub.match_indices(substr).next() { 46 | return ( 47 | low1 + start, 48 | low2 + byte_to_char_map[startb], 49 | matchstr.chars().count(), 50 | ); 51 | } 52 | } 53 | } 54 | (low1, low2, 0) 55 | } 56 | -------------------------------------------------------------------------------- /src/entry/extension_entry.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | 3 | use gtk::{ 4 | gdk_pixbuf::{Pixbuf, PixbufLoader}, 5 | prelude::*, 6 | }; 7 | 8 | use crate::{ 9 | extension::response::{ 10 | ExtensionResponseIcon, ExtensionResponseIconType, ExtensionResponseLine, OnEnterFn, 11 | }, 12 | launcher::util::icon::load_icon, 13 | }; 14 | 15 | pub struct ExtensionEntry { 16 | pub extension_name: String, 17 | pub name: String, 18 | pub description: String, 19 | pub icon: ExtensionResponseIcon, 20 | pub on_enter: OnEnterFn, 21 | } 22 | 23 | impl ExtensionEntry { 24 | pub fn new(extension_name: &str, line: ExtensionResponseLine) -> Self { 25 | Self { 26 | extension_name: extension_name.to_string(), 27 | name: line.name, 28 | description: line.description, 29 | icon: line.icon, 30 | on_enter: line.on_enter, 31 | } 32 | } 33 | 34 | pub fn icon(&self) -> Pixbuf { 35 | match self.icon.type_ { 36 | ExtensionResponseIconType::ThemedIcon => load_icon(&self.icon.value, 40), 37 | ExtensionResponseIconType::SVGStringIcon => { 38 | let loader = PixbufLoader::new(); 39 | loader.write(self.icon.value.as_bytes()).unwrap(); 40 | loader.close().unwrap(); 41 | 42 | loader.pixbuf().unwrap() 43 | } 44 | } 45 | } 46 | } 47 | 48 | impl fmt::Debug for ExtensionEntry { 49 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 50 | f.debug_struct("Ext") 51 | .field("extension_name", &self.extension_name) 52 | .field("name", &self.name) 53 | .field("description", &self.description) 54 | .field("icon", &self.icon) 55 | .finish() 56 | } 57 | } 58 | 59 | impl Clone for ExtensionEntry { 60 | fn clone(&self) -> Self { 61 | Self { 62 | extension_name: self.extension_name.clone(), 63 | name: self.name.clone(), 64 | description: self.description.clone(), 65 | icon: self.icon.clone(), 66 | on_enter: self.on_enter.clone(), 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/entry/mod.rs: -------------------------------------------------------------------------------- 1 | use gtk::gdk_pixbuf::Pixbuf; 2 | 3 | use crate::{ 4 | extension::{config::ExtensionConfig, ExtensionContext}, 5 | launcher::{ 6 | util::{config::Config, icon::default_pixbuf}, 7 | window::Window, 8 | }, 9 | }; 10 | 11 | pub mod app_entry; 12 | pub mod extension_entry; 13 | pub mod script_entry; 14 | 15 | #[derive(Debug, Clone)] 16 | pub enum ResultEntry { 17 | App(app_entry::AppEntry), 18 | Extension(extension_entry::ExtensionEntry), 19 | Script(script_entry::ScriptEntry), 20 | None, 21 | } 22 | 23 | impl ResultEntry { 24 | pub fn name(&self) -> &str { 25 | match self { 26 | ResultEntry::App(app) => &app.name, 27 | ResultEntry::Extension(ext) => &ext.name, 28 | ResultEntry::Script(script) => script.name(), 29 | ResultEntry::None => "No results", 30 | } 31 | } 32 | 33 | pub fn description(&self) -> &str { 34 | match self { 35 | ResultEntry::App(app) => &app.description, 36 | ResultEntry::Extension(ext) => &ext.description, 37 | ResultEntry::Script(script) => script.desc(), 38 | ResultEntry::None => "No results found.", 39 | } 40 | } 41 | 42 | pub fn icon(&self) -> Pixbuf { 43 | match self { 44 | ResultEntry::App(app) => app.icon(), 45 | ResultEntry::Extension(ext) => ext.icon(), 46 | ResultEntry::Script(script) => script.icon(), 47 | ResultEntry::None => default_pixbuf(40), 48 | } 49 | } 50 | 51 | pub fn execute(&self, window: Window) { 52 | match self { 53 | ResultEntry::App(app) => app.execute(window), 54 | ResultEntry::Extension(ext) => { 55 | if let Some(on_enter) = ext.on_enter.as_ref() { 56 | let config = Config::read(); 57 | on_enter(ExtensionContext { 58 | name: ext.extension_name.clone(), 59 | window, 60 | input: None, 61 | config: ExtensionConfig::new(&config, &ext.extension_name), 62 | }) 63 | } 64 | } 65 | ResultEntry::Script(script) => script.run(), 66 | ResultEntry::None => (), 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /data/themes/light/reset.css: -------------------------------------------------------------------------------- 1 | /* @import this colorsheet to get the default values for every property. 2 | * This is useful when writing special CSS tests that should not be 3 | * inluenced by themes - not even the default ones. 4 | * Keep in mind that the output will be very ugly and not look like 5 | * anything GTK. 6 | * Also, when adding new style properties, please add them here. 7 | */ 8 | 9 | * { 10 | color: inherit; 11 | font-size: inherit; 12 | background-color: initial; 13 | font-family: inherit; 14 | font-style: inherit; 15 | font-variant: inherit; 16 | font-weight: inherit; 17 | text-shadow: inherit; 18 | -icon-shadow: inherit; 19 | box-shadow: initial; 20 | margin-top: initial; 21 | margin-bottom: initial; 22 | padding-top: initial; 23 | padding-left: initial; 24 | padding-bottom: initial; 25 | padding-right: initial; 26 | border-top-style: initial; 27 | border-top-width: initial; 28 | border-left-style: initial; 29 | border-left-width: initial; 30 | border-bottom-style: initial; 31 | border-bottom-width: initial; 32 | border-right-style: initial; 33 | border-right-width: initial; 34 | border-top-left-radius: initial; 35 | border-top-right-radius: initial; 36 | border-bottom-right-radius: initial; 37 | border-bottom-left-radius: initial; 38 | outline-style: initial; 39 | outline-width: initial; 40 | outline-offset: initial; 41 | background-clip: initial; 42 | background-origin: initial; 43 | background-size: initial; 44 | background-position: initial; 45 | border-top-color: initial; 46 | border-right-color: initial; 47 | border-bottom-color: initial; 48 | border-left-color: initial; 49 | outline-color: initial; 50 | background-repeat: initial; 51 | background-image: initial; 52 | border-image-source: initial; 53 | border-image-repeat: initial; 54 | border-image-slice: initial; 55 | border-image-width: initial; 56 | transition-property: initial; 57 | transition-duration: initial; 58 | transition-timing-function: initial; 59 | transition-delay: initial; 60 | } -------------------------------------------------------------------------------- /src/dlauncher.rs: -------------------------------------------------------------------------------- 1 | use dbus::blocking::Connection; 2 | use dbus_crossroads::{Context, Crossroads, IfaceBuilder}; 3 | use gtk::{ 4 | glib, 5 | glib::{Receiver, Sender}, 6 | prelude::*, 7 | }; 8 | use log::{debug, info}; 9 | 10 | use dlauncher::{ 11 | launcher::{util::config::Config, window::Window}, 12 | util::init_logger, 13 | }; 14 | 15 | fn main() { 16 | init_logger(); 17 | debug!("Starting dlauncher..."); 18 | 19 | let config = Config::read(); 20 | let application = gtk::Application::new(Some("net.launchpad.dlauncher"), Default::default()); 21 | 22 | application.connect_activate(move |application| { 23 | let windows = Window::new(application, &config); 24 | windows.build_ui(); 25 | info!("Started dlauncher"); 26 | 27 | if !config.main.daemon { 28 | // skip initializing a dbus interface if daemon isn't enabled & show window 29 | windows.window.show_all(); 30 | info!("Running in non-daemon mode"); 31 | } else { 32 | debug!("Starting dbus interface"); 33 | let (tx, rx): (Sender, Receiver) = 34 | glib::MainContext::channel(glib::PRIORITY_DEFAULT); 35 | 36 | std::thread::spawn(move || { 37 | let c = Connection::new_session().unwrap(); 38 | c.request_name("com.dlauncher.server", false, true, false) 39 | .unwrap(); 40 | let mut cr = Crossroads::new(); 41 | 42 | let iface_token = cr.register( 43 | "com.dlauncher.server", 44 | |b: &mut IfaceBuilder>| { 45 | b.method( 46 | "OpenWindow", 47 | (), 48 | (), 49 | move |_: &mut Context, thread_tx, (): ()| { 50 | thread_tx.send(true).unwrap(); 51 | Ok(()) 52 | }, 53 | ); 54 | }, 55 | ); 56 | 57 | cr.insert("/open", &[iface_token], tx); 58 | cr.serve(&c).unwrap(); 59 | }); 60 | 61 | rx.attach(None, move |msg| { 62 | if msg { 63 | debug!("Received message from dbus interface, showing window."); 64 | windows.show_window(); 65 | } 66 | 67 | Continue(true) 68 | }); 69 | }; 70 | }); 71 | 72 | application.run(); 73 | } 74 | -------------------------------------------------------------------------------- /src/launcher/navigation.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use crate::launcher::result::ResultWidget; 4 | 5 | use super::util::query_history::QueryHistory; 6 | 7 | #[derive(Debug, Clone)] 8 | pub struct Navigation { 9 | pub results: Vec, 10 | pub query_history: Arc, 11 | pub selected: Option, 12 | } 13 | 14 | impl Navigation { 15 | pub fn new(query_history: Arc) -> Self { 16 | Self { 17 | results: vec![], 18 | selected: None, 19 | query_history, 20 | } 21 | } 22 | 23 | pub fn select_default(&mut self, query: &str) { 24 | let previous = self.query_history.find(query); 25 | 26 | if let Some(previous) = previous { 27 | for (i, result) in self.results.iter().enumerate() { 28 | if result.entry.name() == previous { 29 | self.select(i as u16); 30 | break; 31 | } 32 | } 33 | } else { 34 | self.select(0); 35 | } 36 | } 37 | 38 | pub fn set_indicies(&mut self) { 39 | for (i, result) in self.results.iter_mut().enumerate() { 40 | result.index = i as u16; 41 | } 42 | } 43 | 44 | pub fn select(&mut self, mut index: u16) { 45 | if index as usize >= self.results.len() { 46 | index = 0; 47 | } 48 | 49 | if let Some(selected) = self.selected { 50 | if selected >= self.results.len() as u16 { 51 | self.selected = None; 52 | } else { 53 | self.results[selected as usize].deselect(); 54 | } 55 | } 56 | 57 | if !self.results.is_empty() { 58 | self.selected = Some(index); 59 | self.results[index as usize].select(); 60 | } else { 61 | self.selected = None; 62 | } 63 | } 64 | 65 | pub fn go_up(&mut self) { 66 | if let Some(selected) = self.selected { 67 | if selected > 0 { 68 | self.select(selected - 1); 69 | } else { 70 | self.select(self.results.len() as u16 - 1); 71 | } 72 | } 73 | } 74 | 75 | pub fn go_down(&mut self) { 76 | if let Some(selected) = self.selected { 77 | let next = selected + 1; 78 | if next < self.results.len() as u16 { 79 | self.select(next); 80 | } else { 81 | self.select(0); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/launcher/util/theme.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{read, read_to_string, write}, 3 | path::PathBuf, 4 | }; 5 | 6 | use serde::{Deserialize, Serialize}; 7 | 8 | use crate::launcher::util::config::Config; 9 | 10 | #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 11 | pub struct ThemeJson { 12 | pub manifest_version: String, 13 | pub name: String, 14 | pub display_name: String, 15 | pub extend_theme: Option, 16 | pub css_file: String, 17 | #[serde(rename = "css_file_gtk_3.20+")] 18 | pub css_file_gtk_3_20: Option, 19 | pub matched_text_hl_colors: MatchedTextHlColors, 20 | } 21 | 22 | #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 23 | pub struct MatchedTextHlColors { 24 | pub when_selected: String, 25 | pub when_not_selected: String, 26 | } 27 | 28 | pub struct Theme { 29 | pub inner: ThemeJson, 30 | config: Config, 31 | } 32 | 33 | impl Theme { 34 | pub fn new(config: Config, bytes: &[u8]) -> Self { 35 | let inner = serde_json::from_slice(bytes).unwrap(); 36 | 37 | Self { inner, config } 38 | } 39 | 40 | pub fn read_file(&self) -> String { 41 | read_to_string(self.path().join(&self.inner.css_file)).unwrap() 42 | } 43 | 44 | pub fn path(&self) -> PathBuf { 45 | self.config.dir().join("themes").join(&self.inner.name) 46 | } 47 | 48 | pub fn css_file(&self) -> &str { 49 | self 50 | .inner 51 | .css_file_gtk_3_20 52 | .as_ref() 53 | .unwrap_or(&self.inner.css_file) 54 | } 55 | 56 | pub fn compile_css(&self) -> PathBuf { 57 | let css_file = self.path().join(&self.css_file()); 58 | 59 | if let Some(extend_theme) = &self.inner.extend_theme { 60 | let generated_css = self.path().join("generated.css"); 61 | 62 | let extend_bytes = &read( 63 | self 64 | .config 65 | .dir() 66 | .join("themes") 67 | .join(extend_theme) 68 | .join("manifest.json"), 69 | ) 70 | .unwrap(); 71 | let extend_theme: Theme = Theme::new(self.config.clone(), extend_bytes); 72 | 73 | let st_ = format!( 74 | "@import url({:?});\n\n{}", 75 | extend_theme.compile_css(), 76 | self.read_file(), 77 | ); 78 | write(&generated_css, st_).unwrap(); 79 | 80 | generated_css 81 | } else { 82 | css_file 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /data/themes/light/theme.css: -------------------------------------------------------------------------------- 1 | @import url("reset.css"); 2 | 3 | /** 4 | * App Window 5 | */ 6 | @define-color bg_color #F2F2F2; 7 | @define-color window_shadow rgba(0, 0, 0, 0.5); 8 | @define-color window_bg @bg_color; 9 | @define-color window_border_color #b1b1b1; 10 | @define-color prefs_backgroud #ccc; 11 | 12 | /** 13 | * Input 14 | */ 15 | @define-color selected_bg_color #999; 16 | @define-color selected_fg_color #fafafa; 17 | @define-color input_color #555; 18 | @define-color caret_color lighter(@input_color); 19 | 20 | /** 21 | * Result items 22 | */ 23 | @define-color item_name #333; 24 | @define-color item_text lighter(@item_name); 25 | @define-color item_box_selected #D6D6D6; 26 | @define-color item_text_selected darker(@item_text); 27 | @define-color item_name_selected @item_name; 28 | @define-color item_shortcut_color #777; 29 | @define-color item_shortcut_shadow #fff; 30 | @define-color item_shortcut_color_sel #444; 31 | @define-color item_shortcut_shadow_sel lighter(@item_box_selected); 32 | 33 | .app { 34 | box-shadow: 0 0 5px @window_shadow; 35 | background-color: @window_bg; 36 | border: 1px solid @window_border_color; 37 | border-radius: 4px; 38 | } 39 | 40 | .input { 41 | color: @input_color; 42 | font-size: 170%; 43 | padding: 5px 0 5px 7px; 44 | } 45 | 46 | /** 47 | * Selected text in input 48 | */ 49 | .input *:selected, 50 | .input *:focus, 51 | *:selected:focus { 52 | background-color: alpha (@selected_bg_color, 0.9); 53 | color: @selected_fg_color; 54 | } 55 | 56 | .item-text { 57 | color: @item_text; 58 | } 59 | .item-name { 60 | color: @item_name; 61 | font-size: 120%; 62 | } 63 | 64 | .selected.item-box { 65 | background-color: @item_box_selected; 66 | } 67 | .selected.item-box .item-text { 68 | color: @item_text_selected; 69 | } 70 | .selected.item-box .item-name { 71 | color: @item_name_selected; 72 | } 73 | .item-shortcut { 74 | color: @item_shortcut_color; 75 | text-shadow: 1px 1px 1px @item_shortcut_shadow; 76 | } 77 | .selected.item-box .item-shortcut { 78 | color: @item_shortcut_color_sel; 79 | text-shadow: 1px 1px 1px @item_shortcut_shadow_sel; 80 | } 81 | 82 | .item-descr { 83 | font-size: 80%; 84 | } 85 | 86 | 87 | /** 88 | * Small result item 89 | */ 90 | .small-result-item .item-name { 91 | font-size: 100%; 92 | } 93 | 94 | .prefs-btn { 95 | border-radius: 12px; 96 | opacity: 0.8; 97 | } 98 | .prefs-btn:hover { 99 | background-color: @prefs_backgroud; 100 | } 101 | 102 | .no-window-shadow { 103 | margin: -20px; 104 | } -------------------------------------------------------------------------------- /src/script/mod.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{create_dir_all, read_dir, read_to_string}, 3 | path::PathBuf, 4 | }; 5 | 6 | use log::error; 7 | 8 | use crate::{launcher::util::config::Config, util::launch_detached}; 9 | 10 | #[derive(Debug, Clone)] 11 | pub struct ScriptMeta { 12 | pub name: String, 13 | pub desc: String, 14 | pub icon: ScriptIcon, 15 | } 16 | 17 | #[derive(Debug, Clone)] 18 | pub enum ScriptIcon { 19 | Themed(String), 20 | Svg(String), 21 | } 22 | 23 | #[derive(Debug, Clone)] 24 | pub struct Script { 25 | pub meta: ScriptMeta, 26 | pub path: PathBuf, 27 | } 28 | 29 | impl ScriptMeta { 30 | pub fn new(contents: String) -> Self { 31 | let lines = contents.lines(); 32 | let mut meta = ScriptMeta { 33 | name: "".to_string(), 34 | desc: "".to_string(), 35 | icon: ScriptIcon::Themed("".to_string()), 36 | }; 37 | 38 | // probably some other way that is faster than this lol 39 | for line in lines { 40 | if line.starts_with("# Name") { 41 | let name = line.split("# Name ").last().unwrap(); 42 | meta.name = name.trim().to_string(); 43 | } else if line.starts_with("# Desc") { 44 | let desc = line.split("# Desc ").last().unwrap(); 45 | meta.desc = desc.trim().to_string(); 46 | } else if line.starts_with("# Icon-svg") { 47 | let icon = line.split("# Icon-svg ").last().unwrap(); 48 | meta.icon = ScriptIcon::Svg(icon.to_string()); 49 | } else if line.starts_with("# Icon-themed") { 50 | let icon = line.trim().split("# Icon-themed ").last().unwrap(); 51 | meta.icon = ScriptIcon::Themed(icon.to_string()); 52 | } 53 | } 54 | 55 | meta 56 | } 57 | } 58 | 59 | impl Script { 60 | pub fn all(config: &Config) -> Vec { 61 | let scripts_dir = config.dir().join("scripts"); 62 | create_dir_all(&scripts_dir).unwrap(); 63 | 64 | let mut scripts = Vec::new(); 65 | 66 | for dirent in read_dir(&scripts_dir).unwrap() { 67 | let dirent = dirent.unwrap(); 68 | let sc = Script::new(dirent.path()); 69 | if sc.meta.name.is_empty() { 70 | error!( 71 | "Script {} has no name, skipping this script...", 72 | sc.path.display() 73 | ); 74 | } else { 75 | scripts.push(sc); 76 | } 77 | } 78 | 79 | scripts 80 | } 81 | 82 | pub fn new(path: PathBuf) -> Self { 83 | let contents = read_to_string(&path).unwrap(); 84 | let meta = ScriptMeta::new(contents); 85 | Script { path, meta } 86 | } 87 | 88 | pub fn run(&self) { 89 | launch_detached(vec!["sh", "-c", self.path.to_str().unwrap()], vec![]); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/fuzzy/mod.rs: -------------------------------------------------------------------------------- 1 | use std::cmp::max; 2 | 3 | use self::util::find_longest_match; 4 | pub use self::util::slice_utf8; 5 | 6 | mod util; 7 | 8 | // This function is from https://github.com/logannc/fuzzywuzzy-rs/blob/master/src/utils.rs with some modifications 9 | fn _get_matching_blocks<'a>(a: &'a str, b: &'a str) -> Vec<(usize, usize, usize)> { 10 | let flipped; 11 | let (shorter, len1, longer, len2) = { 12 | let a_len = a.chars().count(); 13 | let b_len = b.chars().count(); 14 | if a_len <= b_len { 15 | flipped = false; 16 | (a, a_len, b, b_len) 17 | } else { 18 | flipped = true; 19 | (b, b_len, a, a_len) 20 | } 21 | }; 22 | 23 | let mut queue: Vec<(usize, usize, usize, usize)> = vec![(0, len1, 0, len2)]; 24 | let mut matching_blocks = Vec::new(); 25 | while let Some((low1, high1, low2, high2)) = queue.pop() { 26 | let (i, j, k) = find_longest_match(shorter, longer, low1, high1, low2, high2); 27 | if k != 0 { 28 | matching_blocks.push((i, j, k)); 29 | if low1 < i && low2 < j { 30 | queue.push((low1, i, low2, j)); 31 | } 32 | if i + k < high1 && j + k < high2 { 33 | queue.push((i + k, high1, j + k, high2)); 34 | } 35 | } 36 | } 37 | matching_blocks.sort_unstable(); // Is this necessary? 38 | let (mut i1, mut j1, mut k1) = (0, 0, 0); 39 | let mut non_adjacent = Vec::new(); 40 | for (i2, j2, k2) in matching_blocks { 41 | if i1 + k1 == i2 && j1 + k1 == j2 { 42 | k1 += k2; 43 | } else { 44 | if k1 != 0 { 45 | non_adjacent.push((i1, j1, k1)); 46 | } 47 | i1 = i2; 48 | j1 = j2; 49 | k1 = k2; 50 | } 51 | } 52 | if k1 != 0 { 53 | non_adjacent.push((i1, j1, k1)); 54 | } 55 | non_adjacent.push((len1, len2, 0)); 56 | non_adjacent 57 | .into_iter() 58 | .map(|(i, j, k)| if flipped { (j, i, k) } else { (i, j, k) }) 59 | .collect() 60 | } 61 | 62 | pub type MatchingBlocks = (Vec<(usize, String)>, usize); 63 | pub fn get_matching_blocks(a: &str, b: &str) -> MatchingBlocks { 64 | let mut blocks = _get_matching_blocks(&a.to_lowercase(), &b.to_lowercase()); 65 | blocks.pop(); 66 | 67 | let mut output = Vec::new(); 68 | let mut total_len = 0; 69 | for (_, text_idx, len) in blocks { 70 | let a = slice_utf8(b, text_idx, text_idx + len); 71 | output.push((text_idx, a.to_string())); 72 | total_len += len; 73 | } 74 | 75 | (output, total_len) 76 | } 77 | 78 | pub fn get_score(a: &str, b: &str) -> usize { 79 | let a_len = a.chars().count(); 80 | let b_len = b.chars().count(); 81 | let max_len = max(a_len, b_len); 82 | let (blocks, matching_cars) = get_matching_blocks(a, b); 83 | 84 | let mut base_similarity = (matching_cars as f64) / (a_len as f64); 85 | 86 | for (index, _) in blocks { 87 | let is_word_boundary = index == 0 || slice_utf8(b, index - 1, index) == " "; 88 | if !is_word_boundary { 89 | base_similarity -= 0.5 / a_len as f64; 90 | } 91 | } 92 | 93 | let score = 94 | 100.0 * base_similarity * a_len as f64 / (a_len as f64 + (max_len - a_len) as f64 * 0.001); 95 | 96 | score.round() as usize 97 | } 98 | -------------------------------------------------------------------------------- /src/launcher/result.rs: -------------------------------------------------------------------------------- 1 | use gtk::{prelude::*, Builder, EventBox, Image, Label}; 2 | 3 | use crate::{entry::ResultEntry, fuzzy::{ MatchingBlocks, slice_utf8 }, launcher::window::Window}; 4 | 5 | #[derive(Debug, Clone)] 6 | pub struct ResultWidget { 7 | pub builder: Builder, 8 | pub selected: bool, 9 | pub match_: MatchingBlocks, 10 | pub entry: ResultEntry, 11 | pub index: u16, 12 | pub window: Window, 13 | } 14 | 15 | impl ResultWidget { 16 | pub fn new(entry: ResultEntry, window: Window, match_: MatchingBlocks) -> Self { 17 | let result_str = include_str!("../../data/ui/result.ui"); 18 | let builder = Builder::new(); 19 | builder.add_from_string(result_str).unwrap(); 20 | 21 | let item_name: Label = builder.object("item-name").unwrap(); 22 | let item_icon: Image = builder.object("item-icon").unwrap(); 23 | let item_desc: Label = builder.object("item-descr").unwrap(); 24 | 25 | item_name.set_text(entry.name()); 26 | 27 | let open_tag = format!( 28 | "", 29 | window 30 | .config 31 | .theme() 32 | .inner 33 | .matched_text_hl_colors 34 | .when_selected 35 | ); 36 | let close_tag = ""; 37 | 38 | let name_c = match_.0 39 | .iter() 40 | .rev() 41 | .fold(entry.name().to_string(), |name_c, (index, chars)| { 42 | [slice_utf8(&name_c, 0, *index), 43 | &open_tag, 44 | &chars, 45 | close_tag, 46 | slice_utf8(&name_c, *index + chars.chars().count(), name_c.chars().count())].concat() 47 | }); 48 | 49 | item_name.set_markup(&name_c); 50 | 51 | item_icon.set_from_pixbuf(Some(&entry.icon())); 52 | 53 | item_icon.set_pixel_size(40); 54 | item_icon.set_margin(2); 55 | item_desc.set_text(entry.description()); 56 | 57 | Self { 58 | builder, 59 | selected: false, 60 | match_, 61 | entry, 62 | index: 0, 63 | window, 64 | } 65 | } 66 | 67 | pub fn select(&mut self) { 68 | self.selected = true; 69 | let item_box: EventBox = self.builder.object("item-box").unwrap(); 70 | item_box.style_context().add_class("selected"); 71 | } 72 | 73 | pub fn deselect(&mut self) { 74 | self.selected = false; 75 | let item_box: EventBox = self.builder.object("item-box").unwrap(); 76 | item_box.style_context().remove_class("selected"); 77 | } 78 | 79 | pub fn setup(&self) { 80 | let item_box: EventBox = self.builder.object("item-box").unwrap(); 81 | let result_notify = self.clone(); 82 | item_box.connect_enter_notify_event(move |_, e| { 83 | if e.time() != 0 { 84 | let mut navigation = result_notify.window.navigation.lock().unwrap(); 85 | navigation.select(result_notify.index); 86 | } 87 | 88 | Inhibit(false) 89 | }); 90 | 91 | let result_button = self.clone(); 92 | item_box.connect_button_release_event(move |_, _| { 93 | let navigation = result_button.window.navigation.lock().unwrap(); 94 | 95 | if let Some(selected) = navigation.selected { 96 | if result_button.window.config.main.daemon { 97 | result_button.window.window.hide(); 98 | navigation.results[selected as usize] 99 | .entry 100 | .execute(result_button.window.clone()); 101 | } else { 102 | navigation.results[selected as usize] 103 | .entry 104 | .execute(result_button.window.clone()); 105 | std::process::exit(0); 106 | } 107 | } 108 | 109 | Inhibit(false) 110 | }); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/extension/mod.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../../EXTENSIONS.md")] 2 | 3 | use std::sync::Arc; 4 | 5 | use libloading::{Library, Symbol}; 6 | use log::debug; 7 | 8 | use crate::{ 9 | extension::{config::ExtensionConfig, query::Query}, 10 | launcher::{util::config::Config, window::Window}, 11 | }; 12 | 13 | pub mod config; 14 | pub mod query; 15 | pub mod response; 16 | 17 | /// Function signature used for native extensions 18 | pub type ExtensionOutputFunc = unsafe extern "C" fn(ExtensionContext) -> ExtensionExitCode; 19 | 20 | /// Return codes for native extensions 21 | pub enum ExtensionExitCode { 22 | /// When the extension returns successfully 23 | Ok, 24 | /// If the extension encounters an error, it should return this with an explanation. 25 | /// 26 | /// ``` 27 | /// use dlauncher::extension::ExtensionExitCode; 28 | /// ExtensionExitCode::Error("Failed to do something"); 29 | /// ``` 30 | Error(&'static str), 31 | } 32 | 33 | #[derive(Debug, Clone)] 34 | pub struct Extension { 35 | /// The shared object library 36 | pub library: Arc, 37 | /// Copy of Dlauncher window for use in the extension 38 | pub window: Window, 39 | /// Copy of Dlauncher config for use in the extension 40 | pub config: ExtensionConfig, 41 | /// The extension's name, used for identification and more to keep extensions in line. 42 | pub name: String, 43 | } 44 | 45 | #[derive(Debug, Clone)] 46 | pub struct ExtensionContext { 47 | /// Extensions name 48 | /// 49 | /// Used for building responses 50 | pub name: String, 51 | /// The Dlauncher window, useful when directly interfacing with Dlauncher which allows for great flexibility. 52 | pub window: Window, 53 | /// Input when called through on_input(), this will be `None` if called through other functions that don't require an input. 54 | pub input: Option, 55 | /// The Dlauncher main configuration 56 | pub config: ExtensionConfig, 57 | } 58 | 59 | impl Extension { 60 | pub fn new(window: Window, config: Config, extension_name: String) -> Extension { 61 | unsafe { 62 | let filename = config.dir().join("extensions").join(&extension_name); 63 | let library = Library::new(filename).unwrap(); 64 | 65 | Extension { 66 | library: Arc::new(library), 67 | window, 68 | config: ExtensionConfig::new(&config, &extension_name), 69 | name: extension_name, 70 | } 71 | } 72 | } 73 | 74 | /// on_input is called when a user types something into the input. 75 | pub fn on_input(&self, input: &str) -> ExtensionExitCode { 76 | unsafe { 77 | let output: Symbol = self.library.get(b"on_input").unwrap(); 78 | 79 | output(ExtensionContext { 80 | name: self.name.clone(), 81 | input: Some(Query::from_str(input)), 82 | window: self.window.clone(), 83 | config: self.config.clone(), 84 | }) 85 | } 86 | } 87 | 88 | /// on_init is called when dlauncher is starting. 89 | pub fn on_init(&self) -> ExtensionExitCode { 90 | unsafe { 91 | if let Ok(output) = self.library.get::(b"on_init") { 92 | output(ExtensionContext { 93 | name: self.name.clone(), 94 | input: None, 95 | window: self.window.clone(), 96 | config: self.config.clone(), 97 | }) 98 | } else { 99 | debug!("Extension {} has no on_init function, skipped", self.name); 100 | ExtensionExitCode::Ok 101 | } 102 | } 103 | } 104 | 105 | /// on_open is called when the window is toggled open. 106 | pub fn on_open(&self) -> ExtensionExitCode { 107 | unsafe { 108 | if let Ok(output) = self.library.get::(b"on_open") { 109 | output(ExtensionContext { 110 | name: self.name.clone(), 111 | input: None, 112 | window: self.window.clone(), 113 | config: self.config.clone(), 114 | }) 115 | } else { 116 | debug!("Extension {} has no on_open", self.name); 117 | ExtensionExitCode::Ok 118 | } 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dlauncher (A Rust Ulauncher port) 2 | Basically a one to one copy of Ulauncher, with a different backend. 3 | 4 | # Installing 5 | 6 | ## Arch Linux 7 | Dlauncher is available as an AUR package. Install the [`dlauncher`](https://aur.archlinux.org/packages/dlauncher) package if you do not want to build. Install the [`dlauncher-git`](https://aur.archlinux.org/packages/dlauncher-git) package if you want to build from source. 8 | 9 | ## Building 10 | ```shell 11 | git clone https://github.com/diced/dlauncher 12 | make build 13 | ``` 14 | The executables are located in the `target/release` folder. 15 | 16 | ## Running 17 | If you are using xinit, you can add `dlauncher &` to it. 18 | 19 | ## Toggling the window 20 | If you are running in daemon mode, you can run the `dlauncher-toggle` command to toggle the window from appearing. 21 | 22 | # Migrating from Ulauncher 23 | Due to how Dlauncher is built, it is 100% compatible with Ulauncher themes! All you need to do is move your theme from `~/.config/ulauncher/user-themes` 24 | to `~/.config/dlauncher/themes`. 25 | ```shell 26 | cp -r ~/.config/ulauncher/user-themes/* ~/.config/dlauncher/themes` 27 | ``` 28 | 29 | If you would like to migrate your recent apps that show at the start, you can 30 | 31 | # Why? 32 | I love the way Ulauncher works and looks, but I had some issues: Ulauncher's preferences are controlled through a Webkit frontend, which can consume a lot of memory. This coupled with the fact its using python also contributes to the fact that it uses a lot of memory (it isnt really that much its like a few hundred mb's but can total up to 500 sometimes with "ghost" webkit processes, etc). 33 | 34 | Many other factors such as extensions can also add tons of memory to the process, dlauncher even with ports of the extensions I use, runs at the same 40-60 MB that the base binary runs at. 35 | 36 | # How? & Motivation 37 | Since Ulauncher is made using GTK libraries, it made it easy to create a clone of Ulauncher since I could reuse the design files for Ulauncher (which is what I did). After doing so, I could use the code from Ulaunchers codebase, to figure out how it would translate the best in Rust, which was also made very easy due to how similar the GTK and GDK implementations are. 38 | 39 | Once I was able to replicate the same UI that Ulauncher had I started to focus more on the backend, and how extensions would work 40 | 41 | # Extensions? 42 | At the start, extensions would have been a command ran by Dlauncher then its stdout would get parsed yet that did not work well and had absolutely zero functionality. I was able to figure out how to use FFI and shared object libraries (`.so` files) which could be loaded in at runtime using `libloading`. This effectively made extensions much more robust and flexible as to what the developer wanted to do. As of now the API is kind of limited, yet it is possible to do whatever you would like to do. 43 | 44 | # What Changed? 45 | 46 | ## Backend 47 | * The backend is now written in Rust, allowing the launcher to use less resources. 48 | * The way search works might still act different from the original Ulauncher. I found a library called [fuzzywuzzy-rs](https://github.com/logannc/fuzzywuzzy-rs) which had a method called `get_matching_blocks` which I have just decided to copy over to here since I did not want to import this as a dependency/use anything from it except that. 49 | * Recents are stored in a file called `dlauncher.druncache` 50 | * The configuration is entirely based in a file instead of being managed through a UI. (I might add an external program that manages the file, so it doesn't interfere with the main process) 51 | * Extensions (basically entirely different lol) 52 | 53 | Dlauncher runs consistently at around 40-60 MB compared to almost the 200-400 MB that Ulauncher uses (sometimes extensions can make this go up even more). 54 | 55 | ## Frontend 56 | Nothing! Your Ulauncher themes will work perfectly with Dlauncher. 57 | 58 | # Future 59 | I plan to keep working on making Dlauncher more performant! The code also is kinda garbage, any help is appreciated! 60 | 61 | # Copyright Notice 62 | Modifications done to Ulauncher's original source 63 | * data/result.ui 64 | * data/DlauncherWindow.ui 65 | * data/themes/light -------------------------------------------------------------------------------- /data/ui/DlauncherWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | False 8 | True 9 | Dlauncher - Application Launcher 10 | False 11 | center 12 | dlauncher 13 | True 14 | True 15 | True 16 | False 17 | False 18 | 19 | 20 | True 21 | True 22 | False 23 | 20 24 | 20 25 | 20 26 | 20 27 | vertical 28 | 29 | 30 | True 31 | False 32 | 33 | 34 | 30 35 | True 36 | True 37 | True 38 | True 39 | True 40 | True 41 | 20 42 | 20 43 | 15 44 | 15 45 | 48 | 49 | 50 | True 51 | True 52 | 0 53 | 54 | 55 | 56 | 57 | False 58 | True 59 | 0 60 | 61 | 62 | 63 | 64 | True 65 | True 66 | never 67 | in 68 | 500 69 | True 70 | 71 | 72 | True 73 | False 74 | 75 | 76 | True 77 | False 78 | vertical 79 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | False 89 | True 90 | 1 91 | 92 | 93 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /data/ui/result.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | item_frame 8 | True 9 | False 10 | 11 | 12 | True 13 | False 14 | 15 | 16 | True 17 | False 18 | 20 19 | 20 20 | 5 21 | 5 22 | 23 | 24 | True 25 | False 26 | firefox 27 | 30 | 31 | 32 | False 33 | True 34 | 0 35 | 36 | 37 | 38 | 39 | 410 40 | True 41 | False 42 | 12 43 | 12 44 | False 45 | True 46 | vertical 47 | 48 | 49 | True 50 | False 51 | True 52 | middle 53 | 1 54 | 0 55 | 59 | 60 | 61 | False 62 | True 63 | 0 64 | 65 | 66 | 67 | 68 | True 69 | False 70 | True 71 | middle 72 | 1 73 | 0 74 | 78 | 79 | 80 | False 81 | True 82 | 1 83 | 84 | 85 | 86 | 87 | True 88 | True 89 | 1 90 | 91 | 92 | 95 | 96 | 97 | 100 | 101 | 102 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/util.rs: -------------------------------------------------------------------------------- 1 | use std::path::Path; 2 | 3 | use gtk::{ 4 | gdk::SELECTION_CLIPBOARD, 5 | glib::{spawn_async, SpawnFlags}, 6 | Clipboard, 7 | }; 8 | use libc::setsid; 9 | 10 | use crate::{ 11 | entry::app_entry::AppEntry, 12 | fuzzy::{get_matching_blocks, get_score, MatchingBlocks}, 13 | script::Script, 14 | }; 15 | 16 | pub fn no_match() -> MatchingBlocks { 17 | (vec![], 0) 18 | } 19 | 20 | /// Copy `text` to the clipboard. 21 | /// Requires gtk::set_initialized() to be called first if inside an extension. 22 | pub fn copy_to_clipboard(text: &str) { 23 | let clipboard = Clipboard::get(&SELECTION_CLIPBOARD); 24 | clipboard.set_text(text); 25 | clipboard.store(); 26 | } 27 | 28 | /// Checks if `text` matches `comparison` using fuzzy search. The must_be parameter is used to 29 | /// determine what the least text of the match should be. 30 | pub fn matches(query: &str, text: &str, min_score: usize) -> Option { 31 | let score = get_score(query, text); 32 | 33 | if score >= min_score { 34 | Some(get_matching_blocks(query, text)) 35 | } else { 36 | None 37 | } 38 | } 39 | 40 | /// Checks if a user's query matches an apps description, name, and executable file. 41 | pub fn matches_app( 42 | app: &AppEntry, 43 | query: &str, 44 | min_score: usize, 45 | ) -> Option<(MatchingBlocks, usize)> { 46 | let app_score = get_score(query, &app.name); 47 | let score = vec![ 48 | app_score as f64, 49 | get_score(query, &shell_words::join(&app.exec)) as f64 * 0.8, 50 | get_score(query, &app.description) as f64 * 0.7, 51 | ] 52 | .into_iter() 53 | .map(|x| x as usize) 54 | .max() 55 | .unwrap(); 56 | 57 | if score >= min_score { 58 | Some((get_matching_blocks(query, &app.name), app_score)) 59 | } else { 60 | None 61 | } 62 | } 63 | 64 | /// Checks if a user's query matches a scripts description and name. 65 | pub fn matches_script( 66 | script: &Script, 67 | query: &str, 68 | min_score: usize, 69 | ) -> Option<(MatchingBlocks, usize)> { 70 | let script_score = get_score(query, &script.meta.name); 71 | let score = vec![ 72 | script_score as f64, 73 | get_score(query, &script.meta.desc) as f64 * 0.7, 74 | ] 75 | .into_iter() 76 | .map(|x| x as usize) 77 | .max() 78 | .unwrap(); 79 | 80 | if score >= min_score { 81 | Some((get_matching_blocks(query, &script.meta.name), script_score)) 82 | } else { 83 | None 84 | } 85 | } 86 | 87 | /// Initialize a logger, used for extensions. 88 | /// 89 | /// # Example 90 | /// ```rust 91 | /// use dlauncher::extension::ExtensionContext; 92 | /// use dlauncher::util::init_logger; 93 | /// use log::debug; 94 | /// 95 | /// #[no_mangle] 96 | /// pub unsafe extern "C" fn on_init(ctx: ExtensionContext) { 97 | /// init_logger(); 98 | /// debug!("Extension initialized"); // if init_logger was not called then nothing would be printed. 99 | /// } 100 | /// ``` 101 | pub fn init_logger() { 102 | if std::env::var("RUST_LOG").is_err() { 103 | std::env::set_var("RUST_LOG", "info"); 104 | } 105 | 106 | env_logger::init(); 107 | } 108 | 109 | /// Launch a executable that is detached from the main dlauncher program, achieved through 110 | /// `libc::setsid`. Meaning that once dlauncher closes, the executable will continue to run. 111 | /// Due to the way glib works, it asks for Vec<&Path>. You can easily convert a vector of strings to 112 | /// a vector of &Paths. 113 | /// 114 | /// The second argument is additional environment variables that you want to pass to the executable. 115 | /// By default launch_detached uses the environment variables passed to itself. Paths inside of this 116 | /// vector should be formatted as a traditional environment variable `TEST=hello` = 117 | /// `&Path::new("TEST=test")`, it looks a bit weird, but glib requires a Path. 118 | /// 119 | /// # Example 120 | /// An extension that launches dlauncher again when its initialized (I don't know why you would do 121 | /// this). 122 | /// ```rust 123 | /// use dlauncher::util::launch_detached; 124 | /// 125 | /// #[no_mangle] 126 | /// pub unsafe extern "C" fn on_init() { 127 | /// launch_detached(vec![ 128 | /// "/usr/bin/dlauncher" 129 | /// ], vec![]); 130 | /// 131 | /// // dlauncher wouldn't work as run as DISPLAY is not set (example of extra environment variables) 132 | /// launch_detached(vec![ 133 | /// "/usr/bin/dlauncher" 134 | /// ], vec![ 135 | /// "DISPLAY=idk" 136 | /// ]); 137 | /// } 138 | /// ``` 139 | /// 140 | pub fn launch_detached>(spawn_args: Vec, spawn_env_extra: Vec) { 141 | // The things I do for convenience... 142 | let spawn_args = spawn_args 143 | .into_iter() 144 | .map(|x| x.into()) 145 | .collect::>(); 146 | let spawn_args = spawn_args 147 | .iter() 148 | .map(|x| &**x) 149 | .map(Path::new) 150 | .collect::>(); 151 | 152 | let spawn_env_extra = spawn_env_extra 153 | .into_iter() 154 | .map(|x| x.into()) 155 | .collect::>(); 156 | let spawn_env_extra = spawn_env_extra 157 | .iter() 158 | .map(|x| &**x) 159 | .map(Path::new) 160 | .collect::>(); 161 | 162 | let args = std::env::vars(); 163 | let mut formatted = Vec::new(); 164 | 165 | for (k, v) in args { 166 | if k != "GDK_BACKEND" { 167 | formatted.push(format!("{}={}", k, v)); 168 | } 169 | } 170 | 171 | let mut spawn_env: Vec<&Path> = formatted.iter().map(Path::new).collect(); 172 | spawn_env.extend(spawn_env_extra.iter().map(Path::new)); 173 | 174 | spawn_async( 175 | None as Option<&Path>, 176 | spawn_args.as_slice(), 177 | spawn_env.as_slice(), 178 | SpawnFlags::SEARCH_PATH_FROM_ENVP | SpawnFlags::SEARCH_PATH, 179 | Some(Box::new(|| unsafe { 180 | setsid(); 181 | })), 182 | ) 183 | .unwrap(); 184 | } 185 | 186 | /// Open something using xdg-open. 187 | /// 188 | /// # Example 189 | /// ```rust 190 | /// xdg_open(vec!["file:///home/user/"]) // this will open a file manager usually 191 | /// ``` 192 | pub fn xdg_open(args: Vec<&str>, spawn_env_extra: Vec<&str>) { 193 | let mut spawn_args = vec!["xdg-open"]; 194 | spawn_args.extend(args); 195 | 196 | launch_detached(spawn_args, spawn_env_extra); 197 | } 198 | -------------------------------------------------------------------------------- /src/extension/response.rs: -------------------------------------------------------------------------------- 1 | use std::{fmt, rc::Rc}; 2 | 3 | use crate::{ 4 | entry::{extension_entry::ExtensionEntry, ResultEntry}, 5 | extension::ExtensionContext, 6 | fuzzy::MatchingBlocks, 7 | launcher::{result::ResultWidget, window::Window}, 8 | util::no_match, 9 | }; 10 | 11 | #[derive(Debug, Clone)] 12 | /// An extension response, that can create a ResultWidget. 13 | pub struct ExtensionResponse { 14 | extension_name: String, 15 | pub lines: Vec, 16 | } 17 | 18 | pub type OnEnterFn = Rc>>; 19 | /// A line consisting of a name, description, icon, and an optional on_enter function and match vector. 20 | pub struct ExtensionResponseLine { 21 | pub name: String, 22 | pub description: String, 23 | pub icon: ExtensionResponseIcon, 24 | pub match_: MatchingBlocks, 25 | pub on_enter: OnEnterFn, 26 | } 27 | 28 | #[derive(Debug, Clone)] 29 | /// Represents an icon, which can be a themed-icon or an svg string. 30 | pub struct ExtensionResponseIcon { 31 | pub type_: ExtensionResponseIconType, 32 | pub value: String, 33 | } 34 | 35 | #[derive(Debug, Clone)] 36 | pub enum ExtensionResponseIconType { 37 | ThemedIcon, 38 | SVGStringIcon, 39 | } 40 | 41 | impl ExtensionResponse { 42 | /// Initialize a ExtensionResponse Builder, that takes in the extension name. 43 | /// The extension_name **must** be the same as the name returned inside of 44 | /// [ExtensionContext](ExtensionContext) 45 | pub fn builder(extension_name: impl Into) -> Self { 46 | Self { 47 | extension_name: extension_name.into(), 48 | lines: vec![], 49 | } 50 | } 51 | 52 | /// Create a line, that returns ExtensionResponse. This function does not take in a match or on_enter. 53 | pub fn line( 54 | &mut self, 55 | name: impl Into, 56 | description: impl Into, 57 | icon: ExtensionResponseIcon, 58 | ) -> &mut Self { 59 | self.lines.push(ExtensionResponseLine { 60 | name: name.into(), 61 | description: description.into(), 62 | icon, 63 | match_: (vec![], 0), 64 | on_enter: Rc::new(None), 65 | }); 66 | 67 | self 68 | } 69 | 70 | /// Add a line with a match. The match must be a [Vec](Vec)<[usize](usize)>, 71 | /// usually you can get the vector from the [matches](../../util/fn.matches.html) function 72 | pub fn line_match( 73 | &mut self, 74 | name: impl Into, 75 | description: impl Into, 76 | icon: ExtensionResponseIcon, 77 | match_: MatchingBlocks, 78 | ) -> &mut Self { 79 | self.lines.push(ExtensionResponseLine { 80 | name: name.into(), 81 | description: description.into(), 82 | icon, 83 | match_, 84 | on_enter: Rc::new(None), 85 | }); 86 | 87 | self 88 | } 89 | 90 | pub fn line_on_enter( 91 | &mut self, 92 | name: impl Into, 93 | description: impl Into, 94 | icon: ExtensionResponseIcon, 95 | on_enter: F, 96 | ) -> &mut Self 97 | where 98 | F: Fn(ExtensionContext) + 'static, 99 | { 100 | self.lines.push(ExtensionResponseLine { 101 | name: name.into(), 102 | description: description.into(), 103 | icon, 104 | match_: no_match(), 105 | on_enter: Rc::new(Some(Box::new(on_enter))), 106 | }); 107 | 108 | self 109 | } 110 | 111 | pub fn line_match_on_enter( 112 | &mut self, 113 | name: impl Into, 114 | description: impl Into, 115 | icon: ExtensionResponseIcon, 116 | match_: MatchingBlocks, 117 | on_enter: F, 118 | ) -> &mut Self 119 | where 120 | F: Fn(ExtensionContext) + 'static, 121 | { 122 | self.lines.push(ExtensionResponseLine { 123 | name: name.into(), 124 | description: description.into(), 125 | icon, 126 | match_, 127 | on_enter: Rc::new(Some(Box::new(on_enter))), 128 | }); 129 | 130 | self 131 | } 132 | 133 | pub fn build(&self, window: Window) -> Vec { 134 | let mut result = Vec::new(); 135 | 136 | for line in &self.lines { 137 | let entry = ResultEntry::Extension(ExtensionEntry::new(&self.extension_name, line.clone())); 138 | result.push(ResultWidget::new( 139 | entry.clone(), 140 | window.clone(), 141 | line.match_.clone(), 142 | )); 143 | } 144 | 145 | result 146 | } 147 | 148 | pub fn build_and_show(&self, window: Window, override_: bool) { 149 | let result = self.build(window.clone()); 150 | window.show_results(result, override_); 151 | } 152 | } 153 | 154 | impl ExtensionResponseLine { 155 | pub fn builder() -> Self { 156 | Self { 157 | name: String::new(), 158 | description: String::new(), 159 | match_: no_match(), 160 | icon: ExtensionResponseIcon::themed(""), 161 | on_enter: Rc::new(None), 162 | } 163 | } 164 | 165 | pub fn name(&mut self, name: impl Into) -> &mut Self { 166 | self.name = name.into(); 167 | self 168 | } 169 | 170 | pub fn description(&mut self, description: impl Into) -> &mut Self { 171 | self.description = description.into(); 172 | self 173 | } 174 | 175 | pub fn icon(&mut self, icon: ExtensionResponseIcon) -> &mut Self { 176 | self.icon = icon; 177 | self 178 | } 179 | 180 | pub fn match_(&mut self, match_: MatchingBlocks) -> &mut Self { 181 | self.match_ = match_; 182 | self 183 | } 184 | 185 | pub fn on_enter(&mut self, on_enter: fn(ExtensionContext) -> ()) -> &mut Self { 186 | self.on_enter = Rc::new(Some(Box::new(on_enter))); 187 | self 188 | } 189 | } 190 | 191 | impl ExtensionResponseIcon { 192 | pub fn themed(name: impl Into) -> Self { 193 | Self { 194 | type_: ExtensionResponseIconType::ThemedIcon, 195 | value: name.into(), 196 | } 197 | } 198 | 199 | pub fn svg(svg_string: impl Into) -> Self { 200 | Self { 201 | type_: ExtensionResponseIconType::SVGStringIcon, 202 | value: svg_string.into(), 203 | } 204 | } 205 | } 206 | 207 | impl fmt::Debug for ExtensionResponseLine { 208 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 209 | f.debug_struct("ExtensionResponseLine") 210 | .field("name", &self.name) 211 | .field("description", &self.description) 212 | .field("icon", &self.icon) 213 | .field("match_", &self.match_) 214 | .finish() 215 | } 216 | } 217 | 218 | impl Clone for ExtensionResponseLine { 219 | fn clone(&self) -> Self { 220 | Self { 221 | name: self.name.clone(), 222 | description: self.description.clone(), 223 | match_: self.match_.clone(), 224 | icon: self.icon.clone(), 225 | on_enter: self.on_enter.clone(), 226 | } 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /src/launcher/util/config.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{create_dir_all, read, write}, 3 | path::PathBuf, 4 | }; 5 | 6 | use log::{debug, error, info}; 7 | use serde::{Deserialize, Serialize}; 8 | 9 | use crate::{ 10 | extension::{Extension, ExtensionExitCode}, 11 | launcher::{util::theme::Theme, window::Window}, 12 | }; 13 | 14 | #[derive(Debug, Clone, Serialize, Deserialize)] 15 | pub struct Config { 16 | /// Main configuration 17 | pub main: ConfigMain, 18 | /// Launcher options 19 | pub launcher: ConfigLauncher, 20 | /// Keybinds used when navigating through results in the launcher 21 | /// These keybinds are not for opening/toggling the launcher. 22 | pub keybinds: Option, 23 | } 24 | 25 | #[derive(Debug, Clone, Serialize, Deserialize)] 26 | pub struct ConfigMain { 27 | /// Whether to run the launcher in the background. 28 | /// When running in a daemon, you can toggle the window to appear by running `dlauncher-toggle`. 29 | /// 30 | /// If using a window manager or a desktop environment you can use its specific hot key manager and bind a keypress to `dlauncher-toggle`. 31 | pub daemon: bool, 32 | /// Least score for matches made to the query and app name 33 | pub least_score: usize, 34 | /// Extensions (string is the name of the extension) 35 | /// Extensions are located in `($XDG_CONFIG_HOME or ~/.config)/dlauncher/extensions` 36 | /// 37 | /// For more information on how extensions work see [Extensions](../../../extension/index.html) 38 | /// ```toml 39 | /// extensions = ["zero_width_space.so"] 40 | /// ``` 41 | pub extensions: Vec, 42 | } 43 | 44 | #[derive(Debug, Clone, Serialize, Deserialize)] 45 | pub struct ConfigLauncher { 46 | /// Theme for the window 47 | /// Themes are located at `($XDG_CONFIG_HOME or ~/.config)/dlauncher/themes/` 48 | pub color_theme: String, 49 | /// Number of frequent apps to show with no query 50 | pub frequent_apps: u16, 51 | /// Clear input whenever the window is shown (daemon mode) 52 | pub clear_input: bool, 53 | /// Hide when the mouse loses focus on the window 54 | pub hide_on_focus_lost: bool, 55 | /// Run application thorugh a terminal if a desktop entry has `Terminal=true`. `{}` will be replaced with the application's command. 56 | /// 57 | /// Examples: 58 | /// ```toml 59 | /// terminal = 'alacritty -e "{}"' 60 | /// terminal = 'xterm -c "{}"' 61 | /// ``` 62 | pub terminal_command: Option, 63 | } 64 | 65 | #[derive(Debug, Clone, Serialize, Deserialize)] 66 | pub struct ConfigKeybinds { 67 | pub result_up: Option, 68 | pub result_down: Option, 69 | pub close: Option, 70 | pub open: Option, 71 | } 72 | 73 | pub struct Keybinds { 74 | pub result_up: String, 75 | pub result_down: String, 76 | pub close: String, 77 | pub open: String, 78 | } 79 | 80 | impl Config { 81 | pub fn default() -> Self { 82 | Self { 83 | main: ConfigMain { 84 | daemon: true, 85 | least_score: 60, 86 | extensions: vec![], 87 | }, 88 | launcher: ConfigLauncher { 89 | color_theme: "light".to_string(), 90 | frequent_apps: 6, 91 | clear_input: true, 92 | hide_on_focus_lost: true, 93 | terminal_command: None, 94 | }, 95 | keybinds: None, 96 | } 97 | } 98 | 99 | pub fn read() -> Self { 100 | let home = std::env::var("HOME").expect("you are homeless"); 101 | let config_path = PathBuf::from(home).join(".config/dlauncher"); 102 | let abs_config_path = config_path.join("dlauncher.toml"); 103 | 104 | let mut first = false; 105 | let theme = if !abs_config_path.exists() { 106 | first = true; 107 | create_dir_all(&config_path).unwrap(); 108 | 109 | let default = Self::default(); 110 | let bytes = toml::to_vec(&default).unwrap(); 111 | write(&abs_config_path, bytes).unwrap(); 112 | 113 | info!( 114 | "There was no config file found. A default config file has been created at {:#?}", 115 | abs_config_path 116 | ); 117 | 118 | default 119 | } else { 120 | let bytes = read(abs_config_path).unwrap(); 121 | toml::from_slice(&bytes).unwrap() 122 | }; 123 | 124 | if first { 125 | theme.setup(); 126 | } 127 | 128 | theme 129 | } 130 | 131 | pub fn keybinds(&self) -> Keybinds { 132 | let k = self.keybinds.as_ref().unwrap_or(&ConfigKeybinds { 133 | result_up: None, 134 | result_down: None, 135 | close: None, 136 | open: None, 137 | }); 138 | 139 | Keybinds { 140 | result_up: k 141 | .result_up 142 | .as_ref() 143 | .unwrap_or(&"Up".to_string()) 144 | .to_string(), 145 | result_down: k 146 | .result_down 147 | .as_ref() 148 | .unwrap_or(&"Down".to_string()) 149 | .to_string(), 150 | close: k 151 | .close 152 | .as_ref() 153 | .unwrap_or(&"Escape".to_string()) 154 | .to_string(), 155 | open: k.open.as_ref().unwrap_or(&"Return".to_string()).to_string(), 156 | } 157 | } 158 | 159 | pub fn dir(&self) -> PathBuf { 160 | PathBuf::from(std::env::var("HOME").expect("you are homeless")).join(".config/dlauncher") 161 | } 162 | 163 | pub fn themes_dir(&self) -> PathBuf { 164 | self.dir().join("themes") 165 | } 166 | 167 | pub fn setup(&self) { 168 | let theme_path = self.themes_dir().join("light"); 169 | create_dir_all(&theme_path).unwrap(); 170 | create_dir_all(&self.dir().join("extensions")).unwrap(); 171 | create_dir_all(&self.dir().join("scripts")).unwrap(); 172 | 173 | // Copies over default theme. 174 | let default_manifest = include_bytes!("../../../data/themes/light/manifest.json"); 175 | let default_themecss = include_bytes!("../../../data/themes/light/theme.css"); 176 | let default_themegtk = include_bytes!("../../../data/themes/light/theme-gtk-3.20.css"); 177 | let default_resetcss = include_bytes!("../../../data/themes/light/reset.css"); 178 | 179 | write(&theme_path.join("manifest.json"), default_manifest).unwrap(); 180 | write(&theme_path.join("theme.css"), default_themecss).unwrap(); 181 | write(&theme_path.join("theme-gtk-3.20.css"), default_themegtk).unwrap(); 182 | write(&theme_path.join("reset.css"), default_resetcss).unwrap(); 183 | } 184 | 185 | pub fn recents(&self) -> PathBuf { 186 | self.dir().join("dlauncher.druncache") 187 | } 188 | 189 | pub fn theme(&self) -> Theme { 190 | let theme = read( 191 | self 192 | .themes_dir() 193 | .join(&self.launcher.color_theme) 194 | .join("manifest.json"), 195 | ) 196 | .unwrap(); 197 | 198 | Theme::new(self.clone(), &theme) 199 | } 200 | 201 | pub fn extensions(&self, window: &Window) -> Vec { 202 | let exts = self 203 | .main 204 | .extensions 205 | .iter() 206 | .map(|ext| Extension::new(window.clone(), self.clone(), ext.clone())) 207 | .collect::>(); 208 | 209 | for ext in &exts { 210 | debug!("Starting extension {}", ext.name); 211 | match ext.on_init() { 212 | ExtensionExitCode::Ok => info!("Started extension {}", ext.name), 213 | ExtensionExitCode::Error(err) => { 214 | error!("[{}] An error occurred on `on_init`: {}", ext.name, err) 215 | } 216 | } 217 | } 218 | 219 | exts 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/extension/config.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::{create_dir_all, read, write}, 3 | path::PathBuf, 4 | }; 5 | 6 | use dashmap::DashMap; 7 | use log::debug; 8 | use serde::{Deserialize, Serialize}; 9 | 10 | use crate::launcher::util::config::Config; 11 | 12 | #[derive(Debug, Clone, Serialize, Deserialize)] 13 | #[serde(untagged)] 14 | pub enum Value { 15 | /// Used to represent a JSON String value 16 | String(String), 17 | /// Used to represent a JSON numerical value 18 | Number(u64), 19 | /// Used to represent a JSON boolean value 20 | Boolean(bool), 21 | /// Used to represent a JSON array of `Value`s 22 | Array(Vec), 23 | /// Used to represent a JSON object of `String`s to `Value`s 24 | Map(DashMap), 25 | } 26 | 27 | #[derive(Debug, Clone)] 28 | pub struct ExtensionConfig { 29 | file: PathBuf, 30 | map: DashMap, 31 | } 32 | 33 | impl ExtensionConfig { 34 | /// Initialize a "new" extension config based on a extension's name. 35 | /// If the configuration file doesn't already exist it will be populated with an empty JSON object. 36 | /// Calling ExtensionConfig::new() should not be done in extensions as it is provided by the 37 | /// [ExtensionContext](ExtensionContext) struct. 38 | /// 39 | /// The extension's configuration file is stored in 40 | /// `(XDG_CONFIG_HOME or ~/.config)/dlauncher/extension_config` 41 | pub fn new(config: &Config, name: &str) -> Self { 42 | let extension_config_dir = config.dir().join("extension_config"); 43 | create_dir_all(&extension_config_dir).unwrap(); 44 | 45 | let file = extension_config_dir.join(format!("{}.json", name)); 46 | let map = if file.exists() { 47 | debug!( 48 | "Loading extension config for {} from {}", 49 | name, 50 | file.display() 51 | ); 52 | let contents = read(&file).unwrap(); 53 | serde_json::from_slice(&contents).unwrap() 54 | } else { 55 | debug!( 56 | "Creating extension config for {} at {}", 57 | name, 58 | file.display() 59 | ); 60 | let map = DashMap::new(); 61 | write(&file, serde_json::to_vec(&map).unwrap()).unwrap(); 62 | 63 | map 64 | }; 65 | 66 | ExtensionConfig { map, file } 67 | } 68 | 69 | /// Set values. The key will always have to be a string, but the value can be any type that 70 | /// implements Into. 71 | /// Once the map in memory has been updated, it will save the current configuration to the disk 72 | /// 73 | /// # Example 74 | /// *When using config in an extension, use ExtensionContext.config to interface with 75 | /// the config instead of the way this example shows* 76 | /// ```rust 77 | /// use dlauncher::extension::config::ExtensionConfig; 78 | /// 79 | /// let config = ExtensionConfig::new(&config, "test"); 80 | /// config.set("prefix", "time "); 81 | /// ``` 82 | pub fn set>(&self, key: &'static str, value: V) -> Option { 83 | let value = self.map.insert(key.to_string(), value.into()); 84 | self.save(); 85 | 86 | value 87 | } 88 | 89 | /// Get a value from the config. The key will always have to be a string, but the value can be any 90 | /// type that implements From. 91 | /// 92 | /// # Example 93 | /// *When using config in an extension, use ExtensionContext.config to interface with 94 | /// the config instead of the way this example shows* 95 | /// ```rust 96 | /// use dlauncher::extension::config::ExtensionConfig; 97 | /// 98 | /// let config = ExtensionConfig::new(&config, "test"); 99 | /// 100 | /// let prefix: String = config.get("prefix").unwrap(); // panics when the key doesn't exist 101 | /// let some_other_key = config.get::("some_other_key"); 102 | /// ``` 103 | pub fn get>(&self, key: &'static str) -> Option { 104 | self.map.get(key).map(|value| value.value().clone().into()) 105 | } 106 | 107 | /// Check if a key exists in the extension config. 108 | pub fn contains_key(&self, key: &'static str) -> bool { 109 | self.map.contains_key(key) 110 | } 111 | 112 | /// Remove a key from the config. If the key doesn't exist this will return None, and not remove 113 | /// anything. 114 | pub fn remove>(&self, key: &'static str) -> Option { 115 | let val = self.map.remove(key).map(|value| value.1.into()); 116 | self.save(); 117 | val 118 | } 119 | 120 | pub fn len(&self) -> usize { 121 | self.map.len() 122 | } 123 | 124 | pub fn is_empty(&self) -> bool { 125 | self.map.is_empty() 126 | } 127 | 128 | /// Clear the entire configuration, and write it to the disk. 129 | pub fn clear(&self) { 130 | self.map.clear(); 131 | self.save(); 132 | } 133 | 134 | /// Save the current configuration to the disk. 135 | pub fn save(&self) { 136 | write(&self.file, serde_json::to_vec_pretty(&self.map).unwrap()).unwrap(); 137 | } 138 | } 139 | 140 | impl From<&str> for Value { 141 | fn from(s: &str) -> Self { 142 | Value::String(s.to_string()) 143 | } 144 | } 145 | 146 | impl From for Value { 147 | fn from(s: String) -> Self { 148 | Value::String(s) 149 | } 150 | } 151 | 152 | impl From for Value { 153 | fn from(n: u64) -> Self { 154 | Value::Number(n) 155 | } 156 | } 157 | 158 | impl From for Value { 159 | fn from(b: bool) -> Self { 160 | Value::Boolean(b) 161 | } 162 | } 163 | 164 | impl From> for Value { 165 | fn from(v: Vec) -> Self { 166 | Value::Array(v) 167 | } 168 | } 169 | 170 | impl From> for Value { 171 | fn from(v: Vec) -> Self { 172 | Value::Array(v.into_iter().map(|s| s.into()).collect()) 173 | } 174 | } 175 | 176 | impl From> for Value { 177 | fn from(v: Vec) -> Self { 178 | Value::Array(v.into_iter().map(|n| n.into()).collect()) 179 | } 180 | } 181 | 182 | impl From> for Value { 183 | fn from(v: Vec) -> Self { 184 | Value::Array(v.into_iter().map(|b| b.into()).collect()) 185 | } 186 | } 187 | 188 | impl From> for Value { 189 | fn from(m: DashMap) -> Self { 190 | Value::Map(m) 191 | } 192 | } 193 | 194 | impl From for String { 195 | fn from(value: Value) -> Self { 196 | match value { 197 | Value::String(s) => s, 198 | _ => "".to_string(), 199 | } 200 | } 201 | } 202 | 203 | impl From for u64 { 204 | fn from(value: Value) -> Self { 205 | match value { 206 | Value::Number(n) => n, 207 | _ => 0, 208 | } 209 | } 210 | } 211 | 212 | impl From for bool { 213 | fn from(value: Value) -> Self { 214 | match value { 215 | Value::Boolean(b) => b, 216 | _ => false, 217 | } 218 | } 219 | } 220 | 221 | impl From for Vec { 222 | fn from(value: Value) -> Self { 223 | match value { 224 | Value::Array(a) => a, 225 | _ => vec![], 226 | } 227 | } 228 | } 229 | 230 | impl From for Vec { 231 | fn from(value: Value) -> Self { 232 | match value { 233 | Value::Array(a) => a.into_iter().map(|v| v.into()).collect(), 234 | _ => vec![], 235 | } 236 | } 237 | } 238 | 239 | impl From for Vec { 240 | fn from(value: Value) -> Self { 241 | match value { 242 | Value::Array(a) => a.into_iter().map(|v| v.into()).collect(), 243 | _ => vec![], 244 | } 245 | } 246 | } 247 | 248 | impl From for Vec { 249 | fn from(value: Value) -> Self { 250 | match value { 251 | Value::Array(a) => a.into_iter().map(|v| v.into()).collect(), 252 | _ => vec![], 253 | } 254 | } 255 | } 256 | 257 | impl From for DashMap { 258 | fn from(value: Value) -> Self { 259 | match value { 260 | Value::Map(m) => m, 261 | _ => DashMap::new(), 262 | } 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /EXTENSIONS.md: -------------------------------------------------------------------------------- 1 | # Extensions 2 | Extensions allow developers to add new functionality to Dlauncher, for example an extension that lets users search for symbols and copy them to their clipboard. 3 | 4 | # Getting Started 5 | Extensions in Dlauncher are made possible through FFI and shared object libraries (.so files) requiring us to write a lot of unsafe code. 6 | 7 | First setup a new cargo project: 8 | ```shell 9 | cargo new dlauncher_extension 10 | cd dlauncher_extension 11 | ``` 12 | 13 | Then add the following to the `Cargo.toml` file: 14 | ```toml 15 | [dependencies] 16 | dlauncher = "0.1.0" 17 | gtk = { version = "0.15.5", features = ["v3_22"] } 18 | lazy_static = "1.4.0" 19 | log = "0.4.17" 20 | ``` 21 | 22 | Then add the following to the `src/lib.rs` file: 23 | ```rust 24 | use dlauncher::{ 25 | extension::{ 26 | ExtensionContext, 27 | response::{ExtensionResponse, ExtensionResponseIcon}, 28 | }, 29 | }; 30 | use dlauncher::util::init_logger; 31 | use lazy_static::lazy_static; 32 | use log::debug; 33 | 34 | #[no_mangle] 35 | pub unsafe extern "C" fn on_init(ctx: ExtensionContext) { 36 | init_logger(); 37 | 38 | info!("Hello from extension!") 39 | } 40 | ``` 41 | 42 | The `#[no_mangle]` attribute is required to prevent the compiler from mangling the function name so that it can be 43 | called via `on_init` in dlauncher. 44 | The `on_init` function is called when the extension is loaded, this is not required but is useful when the extension 45 | needs to read data before it is used. 46 | We are using the `log` crate to add support for logging, and the `init_logger()` function is used to initialize 47 | the logger for use. 48 | The `ctx` variable is an [`ExtensionContext`](ExtensionContext) struct containing things that let you interface with 49 | the main dlauncher process and window. 50 | 51 | ## Enabling your extension 52 | To test out and debug your extension the easiest way as of now is copy the built .so file to the `extensions` folder. 53 | Before doing this you need to add the file name to the `extensions` array in the `dlauncher.toml` file. 54 | 55 | ```toml 56 | extensions = ["dlauncher_extension.so"] 57 | ``` 58 | 59 | Then we can build the extension, copy it over, then run dlauncher. 60 | ```shell 61 | cargo build --release 62 | cp target/release/libdlauncher_extension.so ~/.config/dlauncher/extensions 63 | 64 | # kill an already running dlauncher 65 | pkill dlauncher 66 | 67 | # this is assuming that the dlauncher bin is inside your PATH or usually /usr/bin 68 | dlauncher 69 | ``` 70 | This can be shortenned into a one liner: 71 | ```shell 72 | cargo build --release && cp target/release/libdlauncher_extension.so ~/.config/dlauncher/extensions && pkill dlauncher && dlauncher 73 | ``` 74 | 75 | ## Listening to input events 76 | To listen to when a user types in the input field we have to add the `on_input` function to the `src/lib.rs`. 77 | 78 | ```rust 79 | use dlauncher::{ 80 | extension::{ 81 | ExtensionContext, 82 | response::{ExtensionResponse, ExtensionResponseIcon}, 83 | }, 84 | }; 85 | use dlauncher::util::init_logger; 86 | use lazy_static::lazy_static; 87 | use log::debug; 88 | 89 | #[no_mangle] 90 | pub unsafe extern "C" fn on_init(ctx: ExtensionContext) { 91 | init_logger(); 92 | 93 | info!("Hello from extension!") 94 | } 95 | 96 | #[no_mangle] 97 | pub unsafe extern "C" fn on_input(ctx: ExtensionContext) { 98 | gtk::set_initialized(); 99 | 100 | info!("input: {:#?}", ctx.input); 101 | } 102 | ``` 103 | 104 | `gtk::set_initialized()` is used to make sure that the gtk library is sure that we initialized it. This is not needed 105 | unless you are interfacing with GTK. 106 | 107 | ## Checking for a match 108 | If we want to see if the users input matches something we can use the [`matches`](../util/fn.matches.html) function. 109 | Heres a function that checks if the users input matches "zero width space". We also make sure that the input is not 110 | [None](None) before we check it. The third argument passed in [`matches`](../util/fn.matches.html) is the least score 111 | required for a match, a safe value for this is usually 60-80, if you want more precision for your match you can use a 112 | higher value like 100-150, just remember that the input has to be very specific and may not yield the best results. Now 113 | if we type in the input field something like "ze" we should see in our logs "matched: true". 114 | ```rust 115 | #[no_mangle] 116 | pub unsafe extern "C" fn on_input(ctx: ExtensionContext) { 117 | gtk::set_initialized(); 118 | 119 | if let Some(input) = ctx.input { 120 | let matched = matches(input, "zero width space", 60); 121 | info!("matched: {}", matched); 122 | } 123 | } 124 | ``` 125 | 126 | ## Adding a result entry 127 | Usually once the match is found we can add a result entry that will show up in the UI. This can be made easy by the 128 | [`ExtensionResponse`](response/struct.ExtensionResponse.html) struct. This will allow you to make a "builder" that will allow you to easily 129 | create a result entry with lines. 130 | 131 | ```rust 132 | #[no_mangle] 133 | pub unsafe extern "C" fn on_input(ctx: ExtensionContext) { 134 | gtk::set_initialized(); 135 | 136 | if let Some(input) = ctx.input { 137 | let matched = matches(input, "zero width space", 60); 138 | if !matched { 139 | return; 140 | } 141 | 142 | let mut response = ExtensionResponse::builder(&ctx.name, None); 143 | response.line( 144 | "Zero Width Space", 145 | "Press enter to copy to your clipboard", 146 | ExtensionResponseIcon::themed("spacer-symbolic") 147 | ); 148 | } 149 | } 150 | ``` 151 | Here, the line function takes 3 arguments: name, description and icon. The [`ExtensionResponseIcon`](response/struct.ExtensionResponseIcon.html) 152 | enum is used to specify the icon that will be used for the result entry. The `themed` function is used to specify a 153 | themed icon, for example using the Papirus icon theme. The `svg` function is used to specify a svg string, which is useful 154 | when you want to use a custom icons, or dynamic icons that can be made on the fly. 155 | 156 | Now when we type in "ze" we should see the result entry showing Zero Width Space with the icon and everything. but when 157 | we press enter the character doesn't get copied to the clipboard. 158 | 159 | ## Controlling what happens when a line is clicked/entered 160 | The [`ExtensionResponse`](response/struct.ExtensionResponse.html) struct has a couple more functions that let you add actions that happen 161 | when the user clicks or presses enter on the line. `ExtensionResponse::line_on_enter` adds a 4th argument that will take 162 | a function. 163 | ```rust 164 | #[no_mangle] 165 | pub unsafe extern "C" fn on_input(ctx: ExtensionContext) { 166 | gtk::set_initialized(); 167 | 168 | if let Some(input) = ctx.input { 169 | let matched = matches(input, "zero width space", 60); 170 | if !matched { 171 | return; 172 | } 173 | 174 | let mut response = ExtensionResponse::builder(&ctx.name, None); 175 | response.line_on_enter( 176 | "Zero Width Space", 177 | "Press enter to copy to your clipboard", 178 | ExtensionResponseIcon::themed("spacer-symbolic"), 179 | |ctx| { 180 | info!("hello! i was clicked"); 181 | } 182 | ); 183 | } 184 | } 185 | ``` 186 | Now when we press enter on the line we should see the print in the logs. Inside the closure we can now use the utility 187 | function [`copy_to_clipboard`](../util/fn.copy_to_clipboard.html) to copy the text to the clipboard. 188 | ```rust 189 | response.line_on_enter( 190 | "Zero Width Space", 191 | "Press enter to copy to your clipboard", 192 | ExtensionResponseIcon::themed("spacer-symbolic"), 193 | |ctx| { 194 | copy_to_clipboard("\u{200B}"); 195 | } 196 | ); 197 | ``` 198 | 199 | # States via static variables 200 | Some extensions might require a prefix, like `sym equal` meaning that `sym` is the prefix and `equal` are the arguments 201 | (This example is refering to an extension that lets you look up symbols and copy them to your clipboard). An inefficient 202 | way of getting the user's prefix would be `ctx.config.get("prefix").unwrap_or("sym")` every time inside your `on_input` 203 | function. To get around this we can use a static variable, and set the value during the `on_init` function. 204 | 205 | To make sure that the value is thread safe and can be mutated we use a [Mutex](Mutex) wrapped in an [Arc](Arc). 206 | We also use [lazy_static](https://crates.io/crates/lazy_static) as normally we can't call functions in static variables. 207 | 208 | We add the following at the top of the file: 209 | ```rust 210 | lazy_static! { 211 | #[derive(Debug)] static ref PREFIX: Arc> = Arc::new(Mutex::new(String::new())); 212 | } 213 | ``` 214 | 215 | Then inside of our `on_init` function we set the value of the static variable: 216 | ```rust 217 | #[no_mangle] 218 | pub unsafe extern "C" fn on_init(ctx: ExtensionContext) { 219 | init_logger(); 220 | 221 | let mut prefix = PREFIX.lock().unwrap(); 222 | *prefix = ctx 223 | .config 224 | .get("prefix") 225 | .unwrap_or_else(|| "sym".to_string()) 226 | + " "; 227 | } 228 | ``` 229 | The following gets a lock of the prefix value, then sets the value of it to the `prefix` key in the extension config, 230 | and if it doesn't exist it sets it to `sym`. 231 | 232 | In our `on_input` function we can now use the static variable to get the prefix: 233 | ```rust 234 | #[no_mangle] 235 | pub unsafe extern "C" fn on_input(ctx: ExtensionContext) { 236 | gtk::set_initialized(); 237 | 238 | if let Some(input) = ctx.input { 239 | let prefix = &*PREFIX.lock().unwrap(); 240 | 241 | if input.is_empty() || !input.to_lowercase().starts_with(prefix) { 242 | return; 243 | } 244 | 245 | // do stuff now. 246 | } 247 | } 248 | ``` 249 | 250 | That's it! Feel free to explore the API, as extensions let you have full control over everything that happens. -------------------------------------------------------------------------------- /src/launcher/window.rs: -------------------------------------------------------------------------------- 1 | use std::sync::{Arc, Mutex}; 2 | 3 | use gtk::{ 4 | gdk::{prelude::*, EventKey}, 5 | prelude::*, 6 | Builder, Entry, EventBox, ScrolledWindow, Window as GtkWindow, 7 | }; 8 | use gtk::glib::idle_add_local; 9 | use log::{debug, error}; 10 | 11 | use crate::{ 12 | entry::{app_entry::AppEntry, script_entry::ScriptEntry, ResultEntry}, 13 | extension::{Extension, ExtensionExitCode}, 14 | fuzzy::MatchingBlocks, 15 | launcher::{ 16 | navigation::Navigation, 17 | result::ResultWidget, 18 | util::{ 19 | app::App, 20 | config::Config, 21 | display::{monitor, scaling_factor}, 22 | query_history::QueryHistory, 23 | recent::Recent, 24 | }, 25 | }, 26 | script::Script, 27 | util::{matches_app, matches_script}, 28 | }; 29 | 30 | #[derive(Debug, Clone)] 31 | pub struct Window { 32 | /// Window state, contains mutatable data. 33 | pub state: WindowState, 34 | /// GTK builder of the window. 35 | pub builder: Builder, 36 | /// Navigation utility, which controls which results are selected, and shown, etc. 37 | pub navigation: Arc>, 38 | /// GTK Window 39 | pub window: GtkWindow, 40 | /// The Dlauncher main configuration usually stored in ~/.config/dlauncher/config.toml 41 | pub config: Config, 42 | /// A list of enabled extensions that are running 43 | pub extensions: Vec, 44 | } 45 | 46 | #[derive(Debug, Clone)] 47 | pub struct WindowState { 48 | /// A list of desktop entries/apps that are eligible to be shown in the results. 49 | pub apps: Arc>>, 50 | /// A list of recent apps that are shown when there is no query or to determine which result 51 | /// should be displayed above another. 52 | pub recents: Arc>>, 53 | /// Query History 54 | pub query_history: Arc, 55 | /// Scripts 56 | pub scripts: Arc>, 57 | } 58 | 59 | #[derive(Debug, Clone)] 60 | pub struct Result { 61 | pub entry: ResultEntry, 62 | pub match_: Vec, 63 | } 64 | 65 | impl Window { 66 | pub fn new(application: >k::Application, config: &Config) -> Self { 67 | let apps = Arc::new(Mutex::new(App::all())); 68 | let recents = Arc::new(Mutex::new(Recent::all(&config.recents()))); 69 | let scripts = Arc::new(Script::all(config)); 70 | let dlauncher_str = include_str!("../../data/ui/DlauncherWindow.ui"); 71 | 72 | let builder = Builder::new(); 73 | builder.add_from_string(dlauncher_str).unwrap(); 74 | 75 | let window: GtkWindow = builder 76 | .object("dlauncher_window") 77 | .expect("Couldn't get window"); 78 | 79 | let visual = window.screen().unwrap().rgba_visual(); 80 | if let Some(visual) = visual { 81 | window.set_visual(Some(&visual)); 82 | } 83 | 84 | window.set_application(Some(application)); 85 | 86 | let query_history = Arc::new(QueryHistory::new(config.clone())); 87 | 88 | let mut sel = Self { 89 | state: WindowState { 90 | apps, 91 | scripts, 92 | recents, 93 | query_history: query_history.clone(), 94 | }, 95 | builder, 96 | navigation: Arc::new(Mutex::new(Navigation::new(query_history))), 97 | window, 98 | config: config.clone(), 99 | extensions: vec![], 100 | }; 101 | 102 | sel.extensions = sel.config.extensions(&sel); 103 | 104 | sel 105 | } 106 | 107 | fn styles(&self) { 108 | let provider = gtk::CssProvider::new(); 109 | provider 110 | .load_from_path( 111 | self 112 | .config 113 | .theme() 114 | .compile_css() 115 | .as_os_str() 116 | .to_str() 117 | .unwrap(), 118 | ) 119 | .unwrap(); 120 | 121 | gtk::StyleContext::add_provider_for_screen( 122 | &self.window.screen().unwrap(), 123 | &provider, 124 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, 125 | ); 126 | 127 | gtk::StyleContext::add_provider( 128 | &self.window.style_context(), 129 | &provider, 130 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, 131 | ); 132 | 133 | for child in self.window.children() { 134 | gtk::StyleContext::add_provider( 135 | &child.style_context(), 136 | &provider, 137 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, 138 | ); 139 | } 140 | 141 | if let Some(visual) = self.window.visual() { 142 | self.window.set_visual(Some(&visual)); 143 | } 144 | } 145 | 146 | fn fix_window_width(&self) { 147 | let (width, height) = self.window.size_request(); 148 | self.window.set_size_request(width + 2, height); 149 | } 150 | 151 | fn position_window(&self) { 152 | let monitor = monitor(); 153 | let geo = monitor.geometry(); 154 | let max_height = geo.height() as f32 - (geo.height() as f32 * 0.15) - 100.0; 155 | let window_width = 500.0 * scaling_factor() + 100.0; 156 | 157 | self 158 | .window 159 | .set_property("width-request", window_width as i32); 160 | let result_box_scroll_container: ScrolledWindow = 161 | self.builder.object("result_box_scroll_container").unwrap(); 162 | result_box_scroll_container.set_property("max-content-height", max_height as i32); 163 | 164 | let x = geo.width() as f32 * 0.5 - window_width * 0.5 + geo.x() as f32; 165 | let y = geo.y() as f32 + geo.height() as f32 * 0.12; 166 | 167 | self.window.move_(x as i32, (y + 92_f32) as i32); 168 | } 169 | 170 | /// Show the GTK window, and refresh the apps and recents. 171 | pub fn show_window(&self) { 172 | self.styles(); 173 | self.window.present(); 174 | self.position_window(); 175 | self.fix_window_width(); 176 | 177 | self.show_results(vec![], false); 178 | self.window.grab_focus(); 179 | 180 | let input: Entry = self.builder.object("input").expect("Couldn't get input"); 181 | if self.config.launcher.clear_input { 182 | input.set_text(""); 183 | } 184 | input.grab_focus(); 185 | } 186 | 187 | pub fn hide_window(&self) { 188 | self.window.hide(); 189 | 190 | let state = self.state.clone(); 191 | let config_recents = self.config.recents(); 192 | 193 | idle_add_local(move || { 194 | let mut apps = state.apps.lock().unwrap(); 195 | let mut recents = state.recents.lock().unwrap(); 196 | *apps = App::all(); 197 | *recents = Recent::all(&config_recents); 198 | 199 | // For some reason the mutex doesn't go out of scope and get automatically dropped so i had to do this. 200 | drop(apps); 201 | drop(recents); 202 | 203 | Continue(false) 204 | }); 205 | } 206 | 207 | /// Add a result widget to the results box 208 | /// 209 | /// Useful for extensions that don't want to clear the entire result box, but just want to add a 210 | /// result widget to the end of the list. 211 | pub fn append_result(&self, result: ResultWidget) { 212 | let mut navigation = self.navigation.lock().unwrap(); 213 | 214 | self.add_one_to_results(&result); 215 | navigation.results.push(result); 216 | navigation.set_indicies(); 217 | 218 | let results = navigation.results.clone(); 219 | 220 | results.iter().for_each(|r| r.setup()); 221 | } 222 | 223 | /// Show multiple result widgets in the results box. This will clear the results box first then 224 | /// add the results. 225 | /// 226 | /// Useful for when extensions want to show their own results without app results. 227 | /// 228 | /// When override is true, it will act like there are no results and show nothing. When it is 229 | /// false, it will show the recent apps (override should be `true` for all extensions!). 230 | pub fn show_results(&self, results: Vec, override_: bool) { 231 | let scroll_box: ScrolledWindow = self.builder.object("result_box_scroll_container").unwrap(); 232 | 233 | if override_ && results.is_empty() { 234 | scroll_box.hide(); 235 | return; 236 | } 237 | 238 | let mut results = if results.is_empty() { 239 | let mut res = self 240 | .state 241 | .recents 242 | .lock() 243 | .unwrap() 244 | .iter() 245 | .map(|recent| recent.to_result(self.clone(), self.state.apps.clone())) 246 | .filter(|result| result.is_some()) 247 | .flatten() 248 | .collect::>(); 249 | 250 | if res.is_empty() { 251 | scroll_box.hide(); 252 | } 253 | 254 | if res.len() > self.config.launcher.frequent_apps as usize { 255 | res.truncate(self.config.launcher.frequent_apps as usize); 256 | } 257 | 258 | res 259 | } else { 260 | results 261 | }; 262 | 263 | let mut navigation = self.navigation.lock().unwrap(); 264 | 265 | self.add_to_results(&results); 266 | navigation.results = results; 267 | navigation.set_indicies(); 268 | 269 | let input: Entry = self.builder.object("input").expect("Couldn't get input"); 270 | navigation.select_default(&input.text()); 271 | 272 | results = navigation.results.clone(); 273 | results.iter().for_each(|r| r.setup()); 274 | } 275 | 276 | fn add_one_to_results(&self, result: &ResultWidget) { 277 | let result_box: gtk::Box = self 278 | .builder 279 | .object("result_box") 280 | .expect("Couldn't get result_box"); 281 | 282 | let object: EventBox = result.builder.object("item-frame").unwrap(); 283 | result_box.add(&object); 284 | 285 | result_box.set_margin_top(3); 286 | result_box.set_margin_bottom(10); 287 | 288 | let scroll_box: ScrolledWindow = self.builder.object("result_box_scroll_container").unwrap(); 289 | 290 | scroll_box.show_all(); 291 | } 292 | 293 | fn add_to_results(&self, apps: &Vec) { 294 | let result_box: gtk::Box = self 295 | .builder 296 | .object("result_box") 297 | .expect("Couldn't get result_box"); 298 | 299 | for child in result_box.children() { 300 | result_box.remove(&child); 301 | } 302 | 303 | if !apps.is_empty() { 304 | for app in apps { 305 | let object: EventBox = app.builder.object("item-frame").unwrap(); 306 | result_box.add(&object); 307 | } 308 | 309 | result_box.set_margin_top(3); 310 | result_box.set_margin_bottom(10); 311 | 312 | let provider = gtk::CssProvider::new(); 313 | provider 314 | .load_from_path( 315 | self 316 | .config 317 | .theme() 318 | .compile_css() 319 | .as_os_str() 320 | .to_str() 321 | .unwrap(), 322 | ) 323 | .unwrap(); 324 | 325 | gtk::StyleContext::add_provider( 326 | &result_box.style_context(), 327 | &provider, 328 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, 329 | ); 330 | 331 | for child in result_box.children() { 332 | gtk::StyleContext::add_provider( 333 | &child.style_context(), 334 | &provider, 335 | gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, 336 | ); 337 | } 338 | 339 | let scroll_box: ScrolledWindow = self.builder.object("result_box_scroll_container").unwrap(); 340 | 341 | scroll_box.show_all(); 342 | } 343 | } 344 | 345 | fn connect_key_press_event(&self, key: &EventKey) -> Inhibit { 346 | let mut navigation = self.navigation.lock().unwrap(); 347 | let input: Entry = self.builder.object("input").expect("Couldn't get input"); 348 | 349 | if let Some(keycode) = key.keyval().name() { 350 | let keycode = keycode.to_string(); 351 | let custom = self.config.keybinds(); 352 | 353 | if keycode == custom.result_up { 354 | navigation.go_up(); 355 | } else if keycode == custom.result_down { 356 | navigation.go_down(); 357 | } else if keycode == custom.open { 358 | if let Some(selected) = navigation.selected { 359 | let entry = &navigation.results[selected as usize].entry; 360 | if !input.text().is_empty() { 361 | self 362 | .state 363 | .query_history 364 | .save_query(input.text(), entry.name()); 365 | debug!("Saved query_history {}: {}", input.text(), entry.name()); 366 | } 367 | 368 | if self.config.main.daemon { 369 | self.hide_window(); 370 | entry.execute(self.clone()); 371 | } else { 372 | entry.execute(self.clone()); 373 | std::process::exit(0); 374 | } 375 | } 376 | } else if keycode == custom.close { 377 | if self.config.main.daemon { 378 | self.hide_window(); 379 | } else { 380 | std::process::exit(0); 381 | } 382 | } 383 | } 384 | 385 | input.grab_focus_without_selecting(); 386 | Inhibit(false) 387 | } 388 | 389 | fn connect_changed(&self, input: &Entry) { 390 | let text = input.text(); 391 | let text = text.trim_start(); 392 | input.set_text(text); 393 | 394 | let mut results = Vec::new(); 395 | 396 | if text.is_empty() { 397 | self.show_results(vec![], false); 398 | } else { 399 | let mut unsort = Vec::new(); 400 | let apps = self.state.apps.lock().unwrap(); 401 | for app in apps.iter() { 402 | if let Some((match_, score)) = matches_app(app, text, self.config.main.least_score) { 403 | unsort.push((ResultEntry::App(app.clone()), self.clone(), match_, score)); 404 | } 405 | } 406 | 407 | for script in self.state.scripts.iter() { 408 | if let Some((match_, score)) = matches_script(script, text, self.config.main.least_score) { 409 | unsort.push(( 410 | ResultEntry::Script(ScriptEntry::new(script.clone())), 411 | self.clone(), 412 | match_, 413 | score, 414 | )); 415 | } 416 | } 417 | 418 | let mut unsort: Vec<(ResultEntry, Window, MatchingBlocks, usize)> = unsort 419 | .into_iter() 420 | .filter(|x| x.3 > x.1.config.main.least_score) 421 | .collect(); 422 | 423 | unsort.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap()); 424 | 425 | results.extend( 426 | unsort 427 | .into_iter() 428 | .map(|(entry, window, match_, _)| ResultWidget::new(entry, window, match_)), 429 | ); 430 | 431 | if results.len() > 9 { 432 | results.truncate(9); 433 | } 434 | 435 | self.show_results(results, true); 436 | 437 | for ext in &self.extensions { 438 | match ext.on_input(text) { 439 | ExtensionExitCode::Error(err) => { 440 | error!("[{}] An error occurred on `on_input`: {}", ext.name, err) 441 | } 442 | _ => {} 443 | } 444 | } 445 | } 446 | } 447 | 448 | pub fn build_ui(&self) { 449 | if !self.config.main.daemon { 450 | self.show_window(); 451 | } 452 | 453 | let input: Entry = self.builder.object("input").expect("Couldn't get input"); 454 | let body: gtk::Box = self.builder.object("body").unwrap(); 455 | body.style_context().add_class("no-window-shadow"); 456 | 457 | let th = self.clone(); 458 | self.window.connect_focus_out_event(move |win, _| { 459 | if th.config.launcher.hide_on_focus_lost { 460 | win.hide(); 461 | } 462 | Inhibit(false) 463 | }); 464 | 465 | let th = self.clone(); 466 | self 467 | .window 468 | .connect_key_press_event(move |_, k| th.connect_key_press_event(k)); 469 | 470 | let th = self.clone(); 471 | input.connect_changed(move |entry| th.connect_changed(entry)); 472 | } 473 | } 474 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "0.7.18" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "anyhow" 16 | version = "1.0.57" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc" 19 | 20 | [[package]] 21 | name = "atk" 22 | version = "0.15.1" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "2c3d816ce6f0e2909a96830d6911c2aff044370b1ef92d7f267b43bae5addedd" 25 | dependencies = [ 26 | "atk-sys", 27 | "bitflags", 28 | "glib", 29 | "libc", 30 | ] 31 | 32 | [[package]] 33 | name = "atk-sys" 34 | version = "0.15.1" 35 | source = "registry+https://github.com/rust-lang/crates.io-index" 36 | checksum = "58aeb089fb698e06db8089971c7ee317ab9644bade33383f63631437b03aafb6" 37 | dependencies = [ 38 | "glib-sys", 39 | "gobject-sys", 40 | "libc", 41 | "system-deps", 42 | ] 43 | 44 | [[package]] 45 | name = "atty" 46 | version = "0.2.14" 47 | source = "registry+https://github.com/rust-lang/crates.io-index" 48 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 49 | dependencies = [ 50 | "hermit-abi", 51 | "libc", 52 | "winapi", 53 | ] 54 | 55 | [[package]] 56 | name = "autocfg" 57 | version = "1.1.0" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 60 | 61 | [[package]] 62 | name = "bitflags" 63 | version = "1.3.2" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 66 | 67 | [[package]] 68 | name = "cairo-rs" 69 | version = "0.15.11" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "62be3562254e90c1c6050a72aa638f6315593e98c5cdaba9017cedbabf0a5dee" 72 | dependencies = [ 73 | "bitflags", 74 | "cairo-sys-rs", 75 | "glib", 76 | "libc", 77 | "thiserror", 78 | ] 79 | 80 | [[package]] 81 | name = "cairo-sys-rs" 82 | version = "0.15.1" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "3c55d429bef56ac9172d25fecb85dc8068307d17acd74b377866b7a1ef25d3c8" 85 | dependencies = [ 86 | "glib-sys", 87 | "libc", 88 | "system-deps", 89 | ] 90 | 91 | [[package]] 92 | name = "cfg-expr" 93 | version = "0.10.2" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "5e068cb2806bbc15b439846dc16c5f89f8599f2c3e4d73d4449d38f9b2f0b6c5" 96 | dependencies = [ 97 | "smallvec", 98 | ] 99 | 100 | [[package]] 101 | name = "cfg-if" 102 | version = "1.0.0" 103 | source = "registry+https://github.com/rust-lang/crates.io-index" 104 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 105 | 106 | [[package]] 107 | name = "dashmap" 108 | version = "5.3.3" 109 | source = "registry+https://github.com/rust-lang/crates.io-index" 110 | checksum = "391b56fbd302e585b7a9494fb70e40949567b1cf9003a8e4a6041a1687c26573" 111 | dependencies = [ 112 | "cfg-if", 113 | "hashbrown", 114 | "lock_api", 115 | "serde", 116 | ] 117 | 118 | [[package]] 119 | name = "dbus" 120 | version = "0.9.5" 121 | source = "registry+https://github.com/rust-lang/crates.io-index" 122 | checksum = "de0a745c25b32caa56b82a3950f5fec7893a960f4c10ca3b02060b0c38d8c2ce" 123 | dependencies = [ 124 | "libc", 125 | "libdbus-sys", 126 | "winapi", 127 | ] 128 | 129 | [[package]] 130 | name = "dbus-crossroads" 131 | version = "0.5.0" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "a5d83c4b78f7c7d0dec4859d286665a06858a607ba406c91a36316ff36918141" 134 | dependencies = [ 135 | "dbus", 136 | ] 137 | 138 | [[package]] 139 | name = "dlauncher" 140 | version = "0.1.1" 141 | dependencies = [ 142 | "dashmap", 143 | "dbus", 144 | "dbus-crossroads", 145 | "env_logger", 146 | "gtk", 147 | "libc", 148 | "libloading", 149 | "log", 150 | "regex", 151 | "serde", 152 | "serde_json", 153 | "shell-words", 154 | "toml", 155 | ] 156 | 157 | [[package]] 158 | name = "env_logger" 159 | version = "0.9.0" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" 162 | dependencies = [ 163 | "atty", 164 | "humantime", 165 | "log", 166 | "regex", 167 | "termcolor", 168 | ] 169 | 170 | [[package]] 171 | name = "field-offset" 172 | version = "0.3.4" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" 175 | dependencies = [ 176 | "memoffset", 177 | "rustc_version", 178 | ] 179 | 180 | [[package]] 181 | name = "futures-channel" 182 | version = "0.3.21" 183 | source = "registry+https://github.com/rust-lang/crates.io-index" 184 | checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" 185 | dependencies = [ 186 | "futures-core", 187 | ] 188 | 189 | [[package]] 190 | name = "futures-core" 191 | version = "0.3.21" 192 | source = "registry+https://github.com/rust-lang/crates.io-index" 193 | checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" 194 | 195 | [[package]] 196 | name = "futures-executor" 197 | version = "0.3.21" 198 | source = "registry+https://github.com/rust-lang/crates.io-index" 199 | checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" 200 | dependencies = [ 201 | "futures-core", 202 | "futures-task", 203 | "futures-util", 204 | ] 205 | 206 | [[package]] 207 | name = "futures-io" 208 | version = "0.3.21" 209 | source = "registry+https://github.com/rust-lang/crates.io-index" 210 | checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" 211 | 212 | [[package]] 213 | name = "futures-task" 214 | version = "0.3.21" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" 217 | 218 | [[package]] 219 | name = "futures-util" 220 | version = "0.3.21" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" 223 | dependencies = [ 224 | "futures-core", 225 | "futures-task", 226 | "pin-project-lite", 227 | "pin-utils", 228 | "slab", 229 | ] 230 | 231 | [[package]] 232 | name = "gdk" 233 | version = "0.15.4" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "a6e05c1f572ab0e1f15be94217f0dc29088c248b14f792a5ff0af0d84bcda9e8" 236 | dependencies = [ 237 | "bitflags", 238 | "cairo-rs", 239 | "gdk-pixbuf", 240 | "gdk-sys", 241 | "gio", 242 | "glib", 243 | "libc", 244 | "pango", 245 | ] 246 | 247 | [[package]] 248 | name = "gdk-pixbuf" 249 | version = "0.15.11" 250 | source = "registry+https://github.com/rust-lang/crates.io-index" 251 | checksum = "ad38dd9cc8b099cceecdf41375bb6d481b1b5a7cd5cd603e10a69a9383f8619a" 252 | dependencies = [ 253 | "bitflags", 254 | "gdk-pixbuf-sys", 255 | "gio", 256 | "glib", 257 | "libc", 258 | ] 259 | 260 | [[package]] 261 | name = "gdk-pixbuf-sys" 262 | version = "0.15.10" 263 | source = "registry+https://github.com/rust-lang/crates.io-index" 264 | checksum = "140b2f5378256527150350a8346dbdb08fadc13453a7a2d73aecd5fab3c402a7" 265 | dependencies = [ 266 | "gio-sys", 267 | "glib-sys", 268 | "gobject-sys", 269 | "libc", 270 | "system-deps", 271 | ] 272 | 273 | [[package]] 274 | name = "gdk-sys" 275 | version = "0.15.1" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | checksum = "32e7a08c1e8f06f4177fb7e51a777b8c1689f743a7bc11ea91d44d2226073a88" 278 | dependencies = [ 279 | "cairo-sys-rs", 280 | "gdk-pixbuf-sys", 281 | "gio-sys", 282 | "glib-sys", 283 | "gobject-sys", 284 | "libc", 285 | "pango-sys", 286 | "pkg-config", 287 | "system-deps", 288 | ] 289 | 290 | [[package]] 291 | name = "gio" 292 | version = "0.15.11" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "0f132be35e05d9662b9fa0fee3f349c6621f7782e0105917f4cc73c1bf47eceb" 295 | dependencies = [ 296 | "bitflags", 297 | "futures-channel", 298 | "futures-core", 299 | "futures-io", 300 | "gio-sys", 301 | "glib", 302 | "libc", 303 | "once_cell", 304 | "thiserror", 305 | ] 306 | 307 | [[package]] 308 | name = "gio-sys" 309 | version = "0.15.10" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "32157a475271e2c4a023382e9cab31c4584ee30a97da41d3c4e9fdd605abcf8d" 312 | dependencies = [ 313 | "glib-sys", 314 | "gobject-sys", 315 | "libc", 316 | "system-deps", 317 | "winapi", 318 | ] 319 | 320 | [[package]] 321 | name = "glib" 322 | version = "0.15.11" 323 | source = "registry+https://github.com/rust-lang/crates.io-index" 324 | checksum = "bd124026a2fa8c33a3d17a3fe59c103f2d9fa5bd92c19e029e037736729abeab" 325 | dependencies = [ 326 | "bitflags", 327 | "futures-channel", 328 | "futures-core", 329 | "futures-executor", 330 | "futures-task", 331 | "glib-macros", 332 | "glib-sys", 333 | "gobject-sys", 334 | "libc", 335 | "once_cell", 336 | "smallvec", 337 | "thiserror", 338 | ] 339 | 340 | [[package]] 341 | name = "glib-macros" 342 | version = "0.15.11" 343 | source = "registry+https://github.com/rust-lang/crates.io-index" 344 | checksum = "25a68131a662b04931e71891fb14aaf65ee4b44d08e8abc10f49e77418c86c64" 345 | dependencies = [ 346 | "anyhow", 347 | "heck", 348 | "proc-macro-crate", 349 | "proc-macro-error", 350 | "proc-macro2", 351 | "quote", 352 | "syn", 353 | ] 354 | 355 | [[package]] 356 | name = "glib-sys" 357 | version = "0.15.10" 358 | source = "registry+https://github.com/rust-lang/crates.io-index" 359 | checksum = "ef4b192f8e65e9cf76cbf4ea71fa8e3be4a0e18ffe3d68b8da6836974cc5bad4" 360 | dependencies = [ 361 | "libc", 362 | "system-deps", 363 | ] 364 | 365 | [[package]] 366 | name = "gobject-sys" 367 | version = "0.15.10" 368 | source = "registry+https://github.com/rust-lang/crates.io-index" 369 | checksum = "0d57ce44246becd17153bd035ab4d32cfee096a657fc01f2231c9278378d1e0a" 370 | dependencies = [ 371 | "glib-sys", 372 | "libc", 373 | "system-deps", 374 | ] 375 | 376 | [[package]] 377 | name = "gtk" 378 | version = "0.15.5" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "92e3004a2d5d6d8b5057d2b57b3712c9529b62e82c77f25c1fecde1fd5c23bd0" 381 | dependencies = [ 382 | "atk", 383 | "bitflags", 384 | "cairo-rs", 385 | "field-offset", 386 | "futures-channel", 387 | "gdk", 388 | "gdk-pixbuf", 389 | "gio", 390 | "glib", 391 | "gtk-sys", 392 | "gtk3-macros", 393 | "libc", 394 | "once_cell", 395 | "pango", 396 | "pkg-config", 397 | ] 398 | 399 | [[package]] 400 | name = "gtk-sys" 401 | version = "0.15.3" 402 | source = "registry+https://github.com/rust-lang/crates.io-index" 403 | checksum = "d5bc2f0587cba247f60246a0ca11fe25fb733eabc3de12d1965fc07efab87c84" 404 | dependencies = [ 405 | "atk-sys", 406 | "cairo-sys-rs", 407 | "gdk-pixbuf-sys", 408 | "gdk-sys", 409 | "gio-sys", 410 | "glib-sys", 411 | "gobject-sys", 412 | "libc", 413 | "pango-sys", 414 | "system-deps", 415 | ] 416 | 417 | [[package]] 418 | name = "gtk3-macros" 419 | version = "0.15.4" 420 | source = "registry+https://github.com/rust-lang/crates.io-index" 421 | checksum = "24f518afe90c23fba585b2d7697856f9e6a7bbc62f65588035e66f6afb01a2e9" 422 | dependencies = [ 423 | "anyhow", 424 | "proc-macro-crate", 425 | "proc-macro-error", 426 | "proc-macro2", 427 | "quote", 428 | "syn", 429 | ] 430 | 431 | [[package]] 432 | name = "hashbrown" 433 | version = "0.12.1" 434 | source = "registry+https://github.com/rust-lang/crates.io-index" 435 | checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" 436 | 437 | [[package]] 438 | name = "heck" 439 | version = "0.4.0" 440 | source = "registry+https://github.com/rust-lang/crates.io-index" 441 | checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 442 | 443 | [[package]] 444 | name = "hermit-abi" 445 | version = "0.1.19" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 448 | dependencies = [ 449 | "libc", 450 | ] 451 | 452 | [[package]] 453 | name = "humantime" 454 | version = "2.1.0" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 457 | 458 | [[package]] 459 | name = "itoa" 460 | version = "1.0.1" 461 | source = "registry+https://github.com/rust-lang/crates.io-index" 462 | checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 463 | 464 | [[package]] 465 | name = "libc" 466 | version = "0.2.124" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" 469 | 470 | [[package]] 471 | name = "libdbus-sys" 472 | version = "0.2.2" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "c185b5b7ad900923ef3a8ff594083d4d9b5aea80bb4f32b8342363138c0d456b" 475 | dependencies = [ 476 | "pkg-config", 477 | ] 478 | 479 | [[package]] 480 | name = "libloading" 481 | version = "0.7.3" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" 484 | dependencies = [ 485 | "cfg-if", 486 | "winapi", 487 | ] 488 | 489 | [[package]] 490 | name = "lock_api" 491 | version = "0.4.7" 492 | source = "registry+https://github.com/rust-lang/crates.io-index" 493 | checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" 494 | dependencies = [ 495 | "autocfg", 496 | "scopeguard", 497 | ] 498 | 499 | [[package]] 500 | name = "log" 501 | version = "0.4.17" 502 | source = "registry+https://github.com/rust-lang/crates.io-index" 503 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 504 | dependencies = [ 505 | "cfg-if", 506 | ] 507 | 508 | [[package]] 509 | name = "memchr" 510 | version = "2.4.1" 511 | source = "registry+https://github.com/rust-lang/crates.io-index" 512 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 513 | 514 | [[package]] 515 | name = "memoffset" 516 | version = "0.6.5" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" 519 | dependencies = [ 520 | "autocfg", 521 | ] 522 | 523 | [[package]] 524 | name = "once_cell" 525 | version = "1.10.0" 526 | source = "registry+https://github.com/rust-lang/crates.io-index" 527 | checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" 528 | 529 | [[package]] 530 | name = "pango" 531 | version = "0.15.10" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "22e4045548659aee5313bde6c582b0d83a627b7904dd20dc2d9ef0895d414e4f" 534 | dependencies = [ 535 | "bitflags", 536 | "glib", 537 | "libc", 538 | "once_cell", 539 | "pango-sys", 540 | ] 541 | 542 | [[package]] 543 | name = "pango-sys" 544 | version = "0.15.10" 545 | source = "registry+https://github.com/rust-lang/crates.io-index" 546 | checksum = "d2a00081cde4661982ed91d80ef437c20eacaf6aa1a5962c0279ae194662c3aa" 547 | dependencies = [ 548 | "glib-sys", 549 | "gobject-sys", 550 | "libc", 551 | "system-deps", 552 | ] 553 | 554 | [[package]] 555 | name = "pest" 556 | version = "2.1.3" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" 559 | dependencies = [ 560 | "ucd-trie", 561 | ] 562 | 563 | [[package]] 564 | name = "pin-project-lite" 565 | version = "0.2.9" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 568 | 569 | [[package]] 570 | name = "pin-utils" 571 | version = "0.1.0" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 574 | 575 | [[package]] 576 | name = "pkg-config" 577 | version = "0.3.25" 578 | source = "registry+https://github.com/rust-lang/crates.io-index" 579 | checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" 580 | 581 | [[package]] 582 | name = "proc-macro-crate" 583 | version = "1.1.3" 584 | source = "registry+https://github.com/rust-lang/crates.io-index" 585 | checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" 586 | dependencies = [ 587 | "thiserror", 588 | "toml", 589 | ] 590 | 591 | [[package]] 592 | name = "proc-macro-error" 593 | version = "1.0.4" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 596 | dependencies = [ 597 | "proc-macro-error-attr", 598 | "proc-macro2", 599 | "quote", 600 | "syn", 601 | "version_check", 602 | ] 603 | 604 | [[package]] 605 | name = "proc-macro-error-attr" 606 | version = "1.0.4" 607 | source = "registry+https://github.com/rust-lang/crates.io-index" 608 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 609 | dependencies = [ 610 | "proc-macro2", 611 | "quote", 612 | "version_check", 613 | ] 614 | 615 | [[package]] 616 | name = "proc-macro2" 617 | version = "1.0.37" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" 620 | dependencies = [ 621 | "unicode-xid", 622 | ] 623 | 624 | [[package]] 625 | name = "quote" 626 | version = "1.0.18" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" 629 | dependencies = [ 630 | "proc-macro2", 631 | ] 632 | 633 | [[package]] 634 | name = "regex" 635 | version = "1.5.5" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" 638 | dependencies = [ 639 | "aho-corasick", 640 | "memchr", 641 | "regex-syntax", 642 | ] 643 | 644 | [[package]] 645 | name = "regex-syntax" 646 | version = "0.6.25" 647 | source = "registry+https://github.com/rust-lang/crates.io-index" 648 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 649 | 650 | [[package]] 651 | name = "rustc_version" 652 | version = "0.3.3" 653 | source = "registry+https://github.com/rust-lang/crates.io-index" 654 | checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" 655 | dependencies = [ 656 | "semver", 657 | ] 658 | 659 | [[package]] 660 | name = "ryu" 661 | version = "1.0.9" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" 664 | 665 | [[package]] 666 | name = "scopeguard" 667 | version = "1.1.0" 668 | source = "registry+https://github.com/rust-lang/crates.io-index" 669 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 670 | 671 | [[package]] 672 | name = "semver" 673 | version = "0.11.0" 674 | source = "registry+https://github.com/rust-lang/crates.io-index" 675 | checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" 676 | dependencies = [ 677 | "semver-parser", 678 | ] 679 | 680 | [[package]] 681 | name = "semver-parser" 682 | version = "0.10.2" 683 | source = "registry+https://github.com/rust-lang/crates.io-index" 684 | checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" 685 | dependencies = [ 686 | "pest", 687 | ] 688 | 689 | [[package]] 690 | name = "serde" 691 | version = "1.0.136" 692 | source = "registry+https://github.com/rust-lang/crates.io-index" 693 | checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" 694 | dependencies = [ 695 | "serde_derive", 696 | ] 697 | 698 | [[package]] 699 | name = "serde_derive" 700 | version = "1.0.136" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" 703 | dependencies = [ 704 | "proc-macro2", 705 | "quote", 706 | "syn", 707 | ] 708 | 709 | [[package]] 710 | name = "serde_json" 711 | version = "1.0.80" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "f972498cf015f7c0746cac89ebe1d6ef10c293b94175a243a2d9442c163d9944" 714 | dependencies = [ 715 | "itoa", 716 | "ryu", 717 | "serde", 718 | ] 719 | 720 | [[package]] 721 | name = "shell-words" 722 | version = "1.1.0" 723 | source = "registry+https://github.com/rust-lang/crates.io-index" 724 | checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" 725 | 726 | [[package]] 727 | name = "slab" 728 | version = "0.4.6" 729 | source = "registry+https://github.com/rust-lang/crates.io-index" 730 | checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" 731 | 732 | [[package]] 733 | name = "smallvec" 734 | version = "1.8.0" 735 | source = "registry+https://github.com/rust-lang/crates.io-index" 736 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 737 | 738 | [[package]] 739 | name = "syn" 740 | version = "1.0.91" 741 | source = "registry+https://github.com/rust-lang/crates.io-index" 742 | checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" 743 | dependencies = [ 744 | "proc-macro2", 745 | "quote", 746 | "unicode-xid", 747 | ] 748 | 749 | [[package]] 750 | name = "system-deps" 751 | version = "6.0.2" 752 | source = "registry+https://github.com/rust-lang/crates.io-index" 753 | checksum = "a1a45a1c4c9015217e12347f2a411b57ce2c4fc543913b14b6fe40483328e709" 754 | dependencies = [ 755 | "cfg-expr", 756 | "heck", 757 | "pkg-config", 758 | "toml", 759 | "version-compare", 760 | ] 761 | 762 | [[package]] 763 | name = "termcolor" 764 | version = "1.1.3" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 767 | dependencies = [ 768 | "winapi-util", 769 | ] 770 | 771 | [[package]] 772 | name = "thiserror" 773 | version = "1.0.30" 774 | source = "registry+https://github.com/rust-lang/crates.io-index" 775 | checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 776 | dependencies = [ 777 | "thiserror-impl", 778 | ] 779 | 780 | [[package]] 781 | name = "thiserror-impl" 782 | version = "1.0.30" 783 | source = "registry+https://github.com/rust-lang/crates.io-index" 784 | checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 785 | dependencies = [ 786 | "proc-macro2", 787 | "quote", 788 | "syn", 789 | ] 790 | 791 | [[package]] 792 | name = "toml" 793 | version = "0.5.9" 794 | source = "registry+https://github.com/rust-lang/crates.io-index" 795 | checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" 796 | dependencies = [ 797 | "serde", 798 | ] 799 | 800 | [[package]] 801 | name = "ucd-trie" 802 | version = "0.1.3" 803 | source = "registry+https://github.com/rust-lang/crates.io-index" 804 | checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" 805 | 806 | [[package]] 807 | name = "unicode-xid" 808 | version = "0.2.2" 809 | source = "registry+https://github.com/rust-lang/crates.io-index" 810 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 811 | 812 | [[package]] 813 | name = "version-compare" 814 | version = "0.1.0" 815 | source = "registry+https://github.com/rust-lang/crates.io-index" 816 | checksum = "fe88247b92c1df6b6de80ddc290f3976dbdf2f5f5d3fd049a9fb598c6dd5ca73" 817 | 818 | [[package]] 819 | name = "version_check" 820 | version = "0.9.4" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 823 | 824 | [[package]] 825 | name = "winapi" 826 | version = "0.3.9" 827 | source = "registry+https://github.com/rust-lang/crates.io-index" 828 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 829 | dependencies = [ 830 | "winapi-i686-pc-windows-gnu", 831 | "winapi-x86_64-pc-windows-gnu", 832 | ] 833 | 834 | [[package]] 835 | name = "winapi-i686-pc-windows-gnu" 836 | version = "0.4.0" 837 | source = "registry+https://github.com/rust-lang/crates.io-index" 838 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 839 | 840 | [[package]] 841 | name = "winapi-util" 842 | version = "0.1.5" 843 | source = "registry+https://github.com/rust-lang/crates.io-index" 844 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 845 | dependencies = [ 846 | "winapi", 847 | ] 848 | 849 | [[package]] 850 | name = "winapi-x86_64-pc-windows-gnu" 851 | version = "0.4.0" 852 | source = "registry+https://github.com/rust-lang/crates.io-index" 853 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 854 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------