├── assets ├── logo.png ├── logo_social.png ├── screenshot.png ├── default_config.toml ├── logo.svg └── logo_social.svg ├── renovate.json ├── .gitignore ├── .cirrus.yml ├── scripts └── passmenu.sh ├── .github └── workflows │ └── ci.yml ├── Cargo.toml ├── src ├── color.rs ├── keybinds.rs ├── main.rs ├── font.rs ├── config.rs ├── selection.rs ├── app.rs └── gui.rs ├── README.md └── LICENSE /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/j0ru/kickoff/HEAD/assets/logo.png -------------------------------------------------------------------------------- /assets/logo_social.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/j0ru/kickoff/HEAD/assets/logo_social.png -------------------------------------------------------------------------------- /assets/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/j0ru/kickoff/HEAD/assets/screenshot.png -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.rs.bk 2 | 3 | # IDE folders 4 | .vscode/ 5 | 6 | # Compilation artifacts 7 | /target 8 | 9 | # Profiling 10 | perf.data* 11 | flame.svg 12 | flamegraph.svg 13 | -------------------------------------------------------------------------------- /.cirrus.yml: -------------------------------------------------------------------------------- 1 | task: 2 | name: FreeBSD (shortest) 3 | freebsd_instance: 4 | matrix: 5 | image_family: freebsd-14-2 6 | install_script: pkg install -y fontconfig pkgconf rust libxkbcommon 7 | script: | 8 | cargo build --release 9 | -------------------------------------------------------------------------------- /scripts/passmenu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | shopt -s nullglob globstar 4 | 5 | prefix=${PASSWORD_STORE_DIR-~/.password-store} 6 | password_files=( "$prefix"/**/*.gpg ) 7 | password_files=( "${password_files[@]#"$prefix"/}" ) 8 | password_files=( "${password_files[@]%.gpg}" ) 9 | 10 | password=$(printf '%s\n' "${password_files[@]}" | kickoff --stdout --from-stdin) 11 | 12 | pass -c "$password" 13 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | 7 | name: Continuous Integration 8 | 9 | jobs: 10 | linux: 11 | name: linux 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | rust: 16 | - stable 17 | - 1.77.0 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: actions-rs/toolchain@v1 21 | with: 22 | profile: minimal 23 | toolchain: ${{ matrix.rust }} 24 | override: true 25 | - run: rustup component add clippy 26 | - run: sudo apt-get install -y libfontconfig-dev pkgconf libxkbcommon-dev 27 | 28 | - name: clippy 29 | uses: actions-rs/cargo@v1 30 | with: 31 | command: clippy 32 | args: -- -D warnings 33 | -------------------------------------------------------------------------------- /assets/default_config.toml: -------------------------------------------------------------------------------- 1 | # Kickoff default config 2 | 3 | # Characters shown in front of the query. 4 | prompt = '' 5 | 6 | # space between window border and the content in pixel 7 | padding = 100 8 | 9 | fonts = [ 10 | 'Noto Sans Mono', 11 | ] # list of otf or ttf fonts. later elements work as fallback 12 | font_size = 32.0 13 | 14 | [search] 15 | show_hidden_files = false 16 | 17 | [history] 18 | decrease_interval = 48 # interval to decrease the number of launches in hours 19 | 20 | [colors] 21 | # color format: rgb or rgba, if transparency is desired 22 | background = '#282c34aa' 23 | prompt = '#abb2bfff' 24 | text = '#ffffffff' # for search results 25 | text_query = '#e5c07bff' # for the search query 26 | text_selected = '#61afefff' # for the currently selected result 27 | 28 | [keybindings] 29 | # keybindings syntax: ctrl/shift/alt/logo as modifiers and a key joined by '+' signs 30 | # A list of available keys can be found here: https://docs.rs/crate/x11-keysymdef/0.2.0/source/src/keysym.json 31 | paste = ["ctrl+v"] 32 | execute = ["KP_Enter", "Return"] 33 | delete = ["KP_Delete", "Delete", "BackSpace"] 34 | delete_word = ["ctrl+KP_Delete", "ctrl+Delete", "ctrl+BackSpace"] 35 | complete = ["Tab"] 36 | nav_up = ["Up"] 37 | nav_down = ["Down"] 38 | exit = ["Escape"] 39 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "kickoff" 3 | version = "0.7.5" 4 | authors = ["Folke Gleumes "] 5 | edition = "2021" 6 | description = "Fast and minimal program launcher" 7 | license = "GPL-3.0-or-later" 8 | homepage = "https://github.com/j0ru/kickoff" 9 | repository = "https://github.com/j0ru/kickoff" 10 | readme = "README.md" 11 | keywords = ["wayland", "launcher", "wlroots"] 12 | rust-version = "1.77" 13 | 14 | [dependencies] 15 | smithay-client-toolkit = "0.19" 16 | fontdue = "0.9" 17 | image = { version = "0.25", default-features = false } 18 | fuzzy-matcher = "0.3" 19 | nix = { version = "0.30", default-features = false, features = ["process"] } 20 | css-color = "0.2" 21 | exec = "0.3" 22 | xdg = "3.0" 23 | toml = "0.8" 24 | serde = { version = "1.0", features = ["derive"] } 25 | log = "0.4" 26 | env_logger = "0.11" 27 | fontconfig = "0.9" 28 | notify-rust = "4.11" 29 | clap = { version = "4.5", features = ["derive"] } 30 | csv = "1.3" 31 | futures = "0.3" 32 | wayland-client = "0.31" 33 | anyhow = "1.0" 34 | wl-clipboard-rs = "0.9" 35 | x11-keysymdef = "0.2.0" 36 | 37 | [dependencies.tokio] 38 | version = "1.44" 39 | features = [ 40 | "fs", 41 | "rt-multi-thread", 42 | "io-util", 43 | "time", 44 | "rt", 45 | "macros", 46 | "io-std", 47 | ] 48 | default-features = false 49 | 50 | [profile.release] 51 | lto = true 52 | debug = true 53 | -------------------------------------------------------------------------------- /src/color.rs: -------------------------------------------------------------------------------- 1 | use image::Rgba; 2 | use serde::de::{self, Visitor}; 3 | use serde::{Deserialize, Deserializer}; 4 | use std::fmt; 5 | use std::str::FromStr; 6 | 7 | #[derive(Clone, Debug)] 8 | pub struct Color(pub u8, pub u8, pub u8, pub u8); 9 | 10 | impl From for Color { 11 | fn from(c: css_color::Rgba) -> Self { 12 | Self( 13 | (c.red * 255. * c.alpha) as u8, 14 | (c.green * 255. * c.alpha) as u8, 15 | (c.blue * 255. * c.alpha) as u8, 16 | (c.alpha * 255.) as u8, 17 | ) 18 | } 19 | } 20 | 21 | impl Color { 22 | pub const fn to_rgba(&self) -> Rgba { 23 | Rgba([self.0, self.1, self.2, self.3]) 24 | } 25 | } 26 | 27 | impl<'de> Deserialize<'de> for Color { 28 | fn deserialize(deserializer: D) -> Result 29 | where 30 | D: Deserializer<'de>, 31 | { 32 | deserializer.deserialize_str(ColorVisitor) 33 | } 34 | } 35 | 36 | struct ColorVisitor; 37 | 38 | impl Visitor<'_> for ColorVisitor { 39 | type Value = Color; 40 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 41 | formatter.write_str("a hex rgb or rgba color value") 42 | } 43 | 44 | fn visit_str(self, value: &str) -> Result 45 | where 46 | E: de::Error, 47 | { 48 | let c = css_color::Rgba::from_str(value); 49 | c.map_or_else(|_| Err(de::Error::custom("")), |c| Ok(Color::from(c))) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | logo 3 |

4 | 5 | Kickoff is heavily inspired by rofi, but not without changes made. 6 | Like many programs, kickoff was born from an itch that no existing program seemed to relieve and my desire to learn a lower-level programming language. 7 | 8 | [![AUR version](https://img.shields.io/aur/version/kickoff?label=kickoff&logo=arch-linux&style=for-the-badge)](https://aur.archlinux.org/packages/kickoff/) 9 | [![Crates Version](https://img.shields.io/crates/v/kickoff?style=for-the-badge)](https://crates.io/crates/kickoff) 10 | 11 | ![screenshot](assets/screenshot.png) 12 | 13 | ## Install 14 | 15 | #### Arch Linux 16 | Use your favorite AUR manager, i.e. [blinky](https://github.com/cherti/blinky/): 17 | 18 | ```bash 19 | blinky -S kickoff 20 | ``` 21 | 22 | #### Cargo 23 | 24 | ```bash 25 | cargo install kickoff 26 | ``` 27 | 28 | ## Features 29 | 30 | - Wayland native (only wlroots based compositors though) 31 | - Fuzzy search 32 | - Fast and snappy 33 | - Remembers often used applications 34 | - Argument support for launched programs 35 | - Paste support 36 | - Custom Input via stdin 37 | 38 | ## How does it search 39 | 40 | All programs found in $PATH are included in the search results. 41 | This can include your additions to $PATH as long as they 42 | are done before you launch kickoff or the program that launches kickoff 43 | (i.e. your window manager) 44 | 45 | This list is then combined with your previous searches and sorted by the amount of usage 46 | and how well it fits the query. 47 | 48 | ## Configuration 49 | 50 | A default configuration will be placed at `$XDG_CONFIG_HOME/kickoff/config.toml` 51 | or can be found [here](https://github.com/j0ru/kickoff/blob/main/assets/default_config.toml). 52 | 53 | ## Script integration 54 | 55 | If you want to adapt kickoff for your use case, i.e. selecting an entry from a password manager, 56 | you can use one of the `--from-*` options. If any of those options is defined, the default behavior of reading from `$PATH` is disabled as well as 57 | saving the history. The latter can easily be reactivated by setting `--history `. 58 | 59 | |Option|Argument|Usage| 60 | |------|--------|-----| 61 | |`--from-stdin`|None| Reads a list of items from stdin | 62 | |`--from-file`|Path| Reads a list of items from a file | 63 | |`--from-path`|None| Walks all `$PATH` directories and adds all executables as selectable items | 64 | |`--stdout`|None| Prints the selected result to stdout instead of trying to execute it | 65 | 66 | These can also be combined, for example, if you want to add custom commands to your usual list of programs. 67 | ```bash 68 | echo 'Big kitty = kitty -o "font_size=20"' | kickoff --from-stdin --from-path --history ".cache/kickoff/custom_history.csv" 69 | ``` 70 | 71 | ### Input Format 72 | 73 | Reading from file or stdin follows a very simple format, 74 | spaces around the equals sign can be dropped: 75 | ``` 76 | Small kitty = kitty -o "font_size=5" 77 | Big kitty = kitty -o "font_size=20" 78 | ^=======^ ^=====================^ 79 | | | 80 | Displayed Name | 81 | | 82 | Executed Command 83 | ``` 84 | 85 | ### Magic Words 86 | 87 | When reading from a file or stdin, you can use magic words to influence the generated items. 88 | Currently, there is only one, but more might be added someday: 89 | 90 | |Word|Argument|Usage|Default| 91 | |----|--------|-----|-------| 92 | |%base_score| number | Sets the base score for all following entries, can be overwritten later | 0 | 93 | 94 | In this example, `Small kitty` has a base score of 0, while the others have a score of 5. 95 | ``` 96 | Small kitty = kitty -o "font_size=5" 97 | %base_score = 5 98 | Big kitty = kitty -o "font_size=20" 99 | Medium kitty = kitty -o "font_size=12" 100 | ``` 101 | -------------------------------------------------------------------------------- /src/keybinds.rs: -------------------------------------------------------------------------------- 1 | use crate::gui::Action; 2 | use serde::de::{self, Visitor}; 3 | use serde::{Deserialize, Deserializer}; 4 | use smithay_client_toolkit::seat::keyboard::{Keysym, Modifiers as ModifiersState}; 5 | use std::collections::HashMap; 6 | use std::fmt; 7 | use std::hash::{Hash, Hasher}; 8 | use x11_keysymdef::lookup_by_name; 9 | 10 | use crate::config::KeybindingsConfig; 11 | 12 | pub struct Keybindings { 13 | inner: HashMap, 14 | } 15 | 16 | impl From for Keybindings { 17 | fn from(config: KeybindingsConfig) -> Self { 18 | let mut res = Self { 19 | inner: HashMap::new(), 20 | }; 21 | 22 | res.add_key_combos(&Action::Complete, &config.complete); 23 | res.add_key_combos(&Action::Execute, &config.execute); 24 | res.add_key_combos(&Action::Exit, &config.exit); 25 | res.add_key_combos(&Action::Delete, &config.delete); 26 | res.add_key_combos(&Action::DeleteWord, &config.delete_word); 27 | res.add_key_combos(&Action::NavUp, &config.nav_up); 28 | res.add_key_combos(&Action::NavDown, &config.nav_down); 29 | res.add_key_combos(&Action::Paste, &config.paste); 30 | 31 | res 32 | } 33 | } 34 | 35 | #[derive(Clone, Default, Debug)] 36 | pub struct Modifiers(ModifiersState); 37 | 38 | impl From for Modifiers { 39 | fn from(modifiers: ModifiersState) -> Self { 40 | Self(modifiers) 41 | } 42 | } 43 | 44 | impl Hash for Modifiers { 45 | fn hash(&self, state: &mut H) { 46 | self.0.alt.hash(state); 47 | self.0.shift.hash(state); 48 | self.0.ctrl.hash(state); 49 | self.0.logo.hash(state); 50 | } 51 | } 52 | 53 | impl PartialEq for Modifiers { 54 | fn eq(&self, other: &Self) -> bool { 55 | self.0.ctrl == other.0.ctrl 56 | && self.0.alt == other.0.alt 57 | && self.0.shift == other.0.shift 58 | && self.0.logo == other.0.logo 59 | } 60 | } 61 | impl Eq for Modifiers {} 62 | 63 | #[derive(Eq, PartialEq, Hash, Clone, fmt::Debug)] 64 | pub struct KeyCombo { 65 | modifiers: Modifiers, 66 | key: Keysym, 67 | } 68 | 69 | impl Keybindings { 70 | pub fn get(&self, modifiers: ModifiersState, keysym: Keysym) -> Option<&Action> { 71 | self.inner.get(&KeyCombo { 72 | modifiers: Modifiers(modifiers), 73 | key: keysym, 74 | }) 75 | } 76 | 77 | fn add_key_combos(&mut self, action: &Action, key_combos: &[KeyCombo]) { 78 | for entry in key_combos { 79 | self.inner.insert(entry.clone(), action.clone()); 80 | } 81 | } 82 | } 83 | 84 | impl KeyCombo { 85 | pub const fn new(modifiers: Modifiers, key: Keysym) -> Self { 86 | Self { modifiers, key } 87 | } 88 | } 89 | 90 | impl<'de> Deserialize<'de> for KeyCombo { 91 | fn deserialize(deserializer: D) -> Result 92 | where 93 | D: Deserializer<'de>, 94 | { 95 | deserializer.deserialize_str(KeyComboVisitor) 96 | } 97 | } 98 | 99 | struct KeyComboVisitor; 100 | impl Visitor<'_> for KeyComboVisitor { 101 | type Value = KeyCombo; 102 | fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 103 | formatter.write_str("assignments of key combinations") 104 | } 105 | 106 | fn visit_str(self, value: &str) -> Result 107 | where 108 | E: de::Error, 109 | { 110 | let mut modifiers = ModifiersState::default(); 111 | let mut key: Option = None; 112 | value.split('+').for_each(|s| match s { 113 | "ctrl" => modifiers.ctrl = true, 114 | "shift" => modifiers.shift = true, 115 | "alt" => modifiers.alt = true, 116 | "logo" => modifiers.logo = true, 117 | s => { 118 | if let Some(value) = lookup_by_name(s) { 119 | key = Some(Keysym::from(value.keysym)); 120 | } 121 | } 122 | }); 123 | key.map_or_else( 124 | || Err(de::Error::custom("No key given or unable to parse")), 125 | |key| { 126 | Ok(KeyCombo { 127 | modifiers: Modifiers(modifiers), 128 | key, 129 | }) 130 | }, 131 | ) 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | #![warn(clippy::nursery)] 2 | #![allow(clippy::cast_possible_truncation)] 3 | 4 | use anyhow::Result; 5 | use app::App; 6 | use clap::Parser; 7 | use config::{Config, History}; 8 | use log::{debug, error, warn}; 9 | use std::time::Instant; 10 | use std::{ 11 | io::{Read, Write}, 12 | {fs, io::ErrorKind}, 13 | {path::PathBuf, process}, 14 | }; 15 | use xdg::BaseDirectories; 16 | 17 | mod app; 18 | mod color; 19 | mod config; 20 | mod font; 21 | mod gui; 22 | mod keybinds; 23 | mod selection; 24 | 25 | #[derive(Parser, Debug)] 26 | pub struct Args { 27 | #[clap(short, long)] 28 | config: Option, 29 | 30 | /// Set custom prompt, overwrites config if set 31 | #[clap(short, long)] 32 | prompt: Option, 33 | 34 | /// Read list from stdin instead of PATH 35 | #[clap(long)] 36 | from_stdin: bool, 37 | 38 | /// Read list from PATH, default true, unless stdin is set 39 | #[clap(long)] 40 | from_path: bool, 41 | 42 | #[clap(long)] 43 | from_file: Vec, 44 | 45 | /// Output selection to stdout instead of executing it 46 | #[clap(long)] 47 | stdout: bool, 48 | 49 | /// Set custom history name. Default history will only be used if stdin is not set 50 | #[clap(long)] 51 | history: Option, 52 | } 53 | 54 | #[cfg(target_os = "linux")] 55 | #[tokio::main] 56 | async fn main() -> Result<()> { 57 | env_logger::init(); 58 | 59 | match put_pid() { 60 | Ok(()) => { 61 | run().await?; 62 | del_pid()?; 63 | Ok(()) 64 | } 65 | Err(e) => { 66 | error!("{e}"); 67 | Ok(()) 68 | } 69 | } 70 | } 71 | 72 | #[cfg(not(target_os = "linux"))] 73 | #[tokio::main] 74 | async fn main() -> Result<()> { 75 | run().await 76 | } 77 | 78 | #[cfg(target_os = "linux")] 79 | fn put_pid() -> std::io::Result<()> { 80 | let xdg_dirs = BaseDirectories::with_prefix("kickoff"); 81 | let pid_path = xdg_dirs.place_runtime_file("kickoff.pid").unwrap(); 82 | match fs::File::open(pid_path.clone()) { 83 | Err(_) => { 84 | let mut pid_file = fs::File::create(pid_path)?; 85 | pid_file.write_all(std::process::id().to_string().as_bytes())?; 86 | Ok(()) 87 | } 88 | Ok(mut file_handle) => { 89 | debug!("Pid file already exists"); 90 | let mut pid = String::new(); 91 | file_handle.read_to_string(&mut pid)?; 92 | if !pid.is_empty() && fs::metadata(format!("/proc/{pid}")).is_ok() { 93 | debug!("Pid from pid file still alive"); 94 | Err(std::io::Error::new( 95 | ErrorKind::Other, 96 | "Kickoff is already running", 97 | )) 98 | } else { 99 | debug!("Pid from kickoff.pid not alive, overwriting..."); 100 | let mut pid_file = fs::File::create(pid_path)?; 101 | pid_file.write_all(std::process::id().to_string().as_bytes())?; 102 | Ok(()) 103 | } 104 | } 105 | } 106 | } 107 | 108 | #[cfg(target_os = "linux")] 109 | fn del_pid() -> std::io::Result<()> { 110 | let xdg_dirs = BaseDirectories::with_prefix("kickoff"); 111 | let pid_path = xdg_dirs.place_runtime_file("kickoff.pid").unwrap(); 112 | std::fs::remove_file(pid_path)?; 113 | Ok(()) 114 | } 115 | 116 | async fn run() -> Result<()> { 117 | let start = Instant::now(); 118 | let args = Args::parse(); 119 | let config = match Config::load(args.config.clone()) { 120 | Ok(c) => c, 121 | Err(e) => { 122 | error!("{e}"); 123 | process::exit(1); 124 | } 125 | }; 126 | 127 | let history = if (!args.from_stdin && args.from_file.is_empty()) || args.history.is_some() { 128 | let path = args.history.clone(); 129 | let decrease_interval = config.history.decrease_interval; 130 | Some(tokio::task::spawn_blocking(move || { 131 | History::load(path, decrease_interval) 132 | })) 133 | } else { 134 | None 135 | }; 136 | 137 | let font = if let Some(font_name) = config.font.clone() { 138 | let mut font_names = config.fonts.clone(); 139 | font_names.insert(0, font_name); 140 | font::Font::new(font_names, config.font_size) 141 | } else { 142 | font::Font::new(config.fonts.clone(), config.font_size) 143 | }; 144 | 145 | let mut apps = selection::ElementListBuilder::new(); 146 | if args.from_path || (!args.from_stdin && args.from_file.is_empty()) { 147 | apps.add_path(config.search.clone()); 148 | } 149 | if !args.from_file.is_empty() { 150 | apps.add_files(&args.from_file); 151 | } 152 | if args.from_stdin { 153 | apps.add_stdin(); 154 | } 155 | let apps = apps.build(); 156 | let mut apps = apps.await?; 157 | 158 | let history = match history { 159 | Some(history) => { 160 | let history = history.await??; 161 | apps.merge_history(&history); 162 | Some(history) 163 | } 164 | None => None, 165 | }; 166 | apps.sort_score(); 167 | 168 | let elapsed = start.elapsed(); 169 | debug!("Time till gui: {elapsed:?}"); 170 | gui::run(App::new(args, config, apps, font.await?, history)); 171 | 172 | Ok(()) 173 | } 174 | -------------------------------------------------------------------------------- /src/font.rs: -------------------------------------------------------------------------------- 1 | use crate::color::Color; 2 | use fontdue::layout::{CoordinateSystem, GlyphRasterConfig, Layout, LayoutSettings, TextStyle}; 3 | use fontdue::Metrics; 4 | use std::cell::RefCell; 5 | use std::collections::HashMap; 6 | use std::path::PathBuf; 7 | 8 | use tokio::{ 9 | fs::File, 10 | io::{self, AsyncReadExt}, 11 | }; 12 | 13 | use fontconfig::Fontconfig; 14 | 15 | use image::{Pixel, RgbaImage}; 16 | 17 | pub struct Font { 18 | fonts: Vec, 19 | layout: RefCell, 20 | size: f32, 21 | scale: i32, 22 | glyph_cache: RefCell)>>, 23 | tab_width: usize, 24 | } 25 | 26 | impl Font { 27 | pub async fn new(font_names: Vec, size: f32) -> io::Result { 28 | let fc = Fontconfig::new().expect("Couldn't load fontconfig"); 29 | let font_names = if font_names.is_empty() { 30 | vec![String::new()] 31 | } else { 32 | font_names 33 | }; 34 | let font_paths: Vec = font_names 35 | .iter() 36 | .map(|name| fc.find(name, None).unwrap().path) 37 | .collect(); 38 | let mut font_data = Vec::new(); 39 | 40 | for font_path in font_paths { 41 | let mut font_buffer = Vec::new(); 42 | File::open(font_path.to_str().unwrap()) 43 | .await? 44 | .read_to_end(&mut font_buffer) 45 | .await?; 46 | font_data.push( 47 | fontdue::Font::from_bytes(font_buffer, fontdue::FontSettings::default()).unwrap(), 48 | ); 49 | } 50 | 51 | Ok(Self { 52 | fonts: font_data, 53 | layout: RefCell::new(Layout::new(CoordinateSystem::PositiveYDown)), 54 | size, 55 | scale: 1, 56 | tab_width: 8, 57 | glyph_cache: RefCell::new(HashMap::new()), 58 | }) 59 | } 60 | 61 | pub fn set_scale(&mut self, scale: i32) { 62 | self.scale = scale; 63 | } 64 | 65 | fn render_glyph(&self, conf: GlyphRasterConfig) -> (Metrics, Vec) { 66 | let mut glyph_cache = self.glyph_cache.borrow_mut(); 67 | 68 | #[allow(clippy::option_if_let_else)] 69 | if let Some(bitmap) = glyph_cache.get(&conf) { 70 | bitmap.clone() 71 | } else { 72 | let font: Vec<&fontdue::Font> = self 73 | .fonts 74 | .iter() 75 | .filter(|f| (*f).file_hash() == conf.font_hash) 76 | .collect(); 77 | glyph_cache.insert(conf, font.first().unwrap().rasterize_config(conf)); 78 | glyph_cache.get(&conf).unwrap().clone() 79 | } 80 | } 81 | 82 | fn replace_tabs(input: &str, tab_width: usize) -> String { 83 | let mut res = String::new(); 84 | for (idx, c) in input.chars().enumerate() { 85 | if c == '\t' { 86 | let tab_alignment = idx % tab_width; 87 | if tab_alignment == 0 { 88 | res.push_str(" ".repeat(8).as_str()); 89 | } else { 90 | res.push_str(" ".repeat(tab_width - tab_alignment).as_str()); 91 | } 92 | } else { 93 | res.push(c); 94 | } 95 | } 96 | 97 | res 98 | } 99 | 100 | pub fn render( 101 | &self, 102 | text: &str, 103 | color: &Color, 104 | image: &mut RgbaImage, 105 | x_offset: u32, 106 | y_offset: u32, 107 | max_width: Option, 108 | ) -> (u32, u32) { 109 | let mut width = 0; 110 | let mut current_width = 0.; 111 | let mut layout = self.layout.borrow_mut(); 112 | layout.reset(&LayoutSettings::default()); 113 | 114 | for c in Self::replace_tabs(text, self.tab_width).chars() { 115 | let mut font_index = 0; 116 | for (i, font) in self.fonts.iter().enumerate() { 117 | if font.lookup_glyph_index(c) != 0 { 118 | font_index = i; 119 | break; 120 | } 121 | } 122 | layout.append( 123 | &self.fonts, 124 | &TextStyle::new(&c.to_string(), self.size * self.scale as f32, font_index), 125 | ); 126 | } 127 | 128 | for glyph in layout.glyphs() { 129 | if let Some(max_width) = max_width { 130 | if current_width as usize + glyph.width > max_width { 131 | break; 132 | } 133 | } 134 | let (metrics, bitmap) = self.render_glyph(glyph.key); 135 | current_width += metrics.advance_width; 136 | for (i, alpha) in bitmap.iter().enumerate() { 137 | if alpha != &0 && glyph.width > 0 { 138 | let x = glyph.x + x_offset as f32 + (i % glyph.width) as f32; 139 | let y = glyph.y + y_offset as f32 + (i / glyph.width) as f32; 140 | 141 | match image.get_pixel_mut_checked(x as u32, y as u32) { 142 | Some(pixel) => { 143 | pixel.blend(&image::Rgba([color.0, color.1, color.2, *alpha])); 144 | } 145 | None => continue, 146 | } 147 | } 148 | } 149 | } 150 | if let Some(glyph) = layout.glyphs().last() { 151 | width = glyph.x as usize + glyph.width; 152 | } 153 | 154 | (width as u32, layout.height() as u32) 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/config.rs: -------------------------------------------------------------------------------- 1 | use crate::color::Color; 2 | use crate::keybinds::{KeyCombo, Modifiers}; 3 | use crate::selection::Element; 4 | use log::info; 5 | use smithay_client_toolkit::seat::keyboard::{Keysym, Modifiers as ModifiersState}; 6 | use std::fmt::Debug; 7 | use std::fs::{read_to_string, write}; 8 | use std::path::PathBuf; 9 | use std::time::SystemTime; 10 | use xdg::BaseDirectories; 11 | 12 | use serde::{Deserialize, Serialize}; 13 | 14 | #[derive(Deserialize, Clone, Debug)] 15 | #[serde(default)] 16 | pub struct ColorConfig { 17 | pub background: Color, 18 | pub text: Color, 19 | pub text_query: Color, 20 | pub text_selected: Color, 21 | pub prompt: Color, 22 | } 23 | 24 | #[derive(Deserialize, Clone, Debug)] 25 | #[serde(default)] 26 | pub struct KeybindingsConfig { 27 | pub delete: Vec, 28 | pub delete_word: Vec, 29 | pub execute: Vec, 30 | pub paste: Vec, 31 | pub complete: Vec, 32 | pub nav_up: Vec, 33 | pub nav_down: Vec, 34 | pub exit: Vec, 35 | } 36 | 37 | #[derive(Deserialize, Clone, Debug)] 38 | #[serde(default)] 39 | pub struct HistoryConfig { 40 | pub decrease_interval: u64, 41 | } 42 | 43 | #[derive(Deserialize, Clone, Debug, Default)] 44 | #[serde(default)] 45 | pub struct SearchConfig { 46 | pub show_hidden_files: bool, 47 | } 48 | 49 | #[derive(Deserialize, Clone, Debug)] 50 | #[serde(default)] 51 | pub struct Config { 52 | pub prompt: String, 53 | pub padding: u32, 54 | pub font: Option, 55 | pub fonts: Vec, 56 | pub font_size: f32, 57 | pub colors: ColorConfig, 58 | pub history: HistoryConfig, 59 | pub keybindings: KeybindingsConfig, 60 | pub search: SearchConfig, 61 | } 62 | 63 | impl Default for KeybindingsConfig { 64 | fn default() -> Self { 65 | Self { 66 | delete: vec![ 67 | KeyCombo::new(Modifiers::default(), Keysym::BackSpace), 68 | KeyCombo::new(Modifiers::default(), Keysym::Delete), 69 | KeyCombo::new(Modifiers::default(), Keysym::KP_Delete), 70 | ], 71 | delete_word: vec![ 72 | KeyCombo::new( 73 | ModifiersState { 74 | ctrl: true, 75 | ..ModifiersState::default() 76 | } 77 | .into(), 78 | Keysym::BackSpace, 79 | ), 80 | KeyCombo::new( 81 | ModifiersState { 82 | ctrl: true, 83 | ..ModifiersState::default() 84 | } 85 | .into(), 86 | Keysym::Delete, 87 | ), 88 | KeyCombo::new( 89 | ModifiersState { 90 | ctrl: true, 91 | ..ModifiersState::default() 92 | } 93 | .into(), 94 | Keysym::KP_Delete, 95 | ), 96 | ], 97 | execute: vec![ 98 | KeyCombo::new(Modifiers::default(), Keysym::Return), 99 | KeyCombo::new(Modifiers::default(), Keysym::KP_Enter), 100 | ], 101 | paste: vec![KeyCombo::new( 102 | ModifiersState { 103 | ctrl: true, 104 | ..ModifiersState::default() 105 | } 106 | .into(), 107 | Keysym::v, 108 | )], 109 | complete: vec![KeyCombo::new(Modifiers::default(), Keysym::Tab)], 110 | nav_up: vec![ 111 | KeyCombo::new(Modifiers::default(), Keysym::Up), 112 | KeyCombo::new(Modifiers::default(), Keysym::KP_Up), 113 | ], 114 | nav_down: vec![ 115 | KeyCombo::new(Modifiers::default(), Keysym::Down), 116 | KeyCombo::new(Modifiers::default(), Keysym::KP_Down), 117 | ], 118 | exit: vec![KeyCombo::new(Modifiers::default(), Keysym::Escape)], 119 | } 120 | } 121 | } 122 | impl Default for ColorConfig { 123 | fn default() -> Self { 124 | Self { 125 | background: Color(40, 44, 52, 170), 126 | prompt: Color(171, 178, 191, 255), 127 | text: Color(255, 255, 255, 255), 128 | text_query: Color(229, 192, 123, 255), 129 | text_selected: Color(97, 175, 239, 255), 130 | } 131 | } 132 | } 133 | impl Default for Config { 134 | fn default() -> Self { 135 | Self { 136 | prompt: String::new(), 137 | padding: 100, 138 | font: None, 139 | fonts: vec![], 140 | font_size: 32., 141 | colors: ColorConfig::default(), 142 | history: HistoryConfig::default(), 143 | keybindings: KeybindingsConfig::default(), 144 | search: SearchConfig::default(), 145 | } 146 | } 147 | } 148 | impl Default for HistoryConfig { 149 | fn default() -> Self { 150 | Self { 151 | decrease_interval: 48, 152 | } 153 | } 154 | } 155 | 156 | impl Config { 157 | pub fn load(config_path: Option) -> Result> { 158 | let xdg_dirs = BaseDirectories::with_prefix("kickoff"); 159 | if let Some(config_file) = config_path { 160 | let content = read_to_string(config_file)?; 161 | Ok(toml::from_str(&content)?) 162 | } else if let Some(config_file) = xdg_dirs.find_config_file("config.toml") { 163 | let content = read_to_string(config_file)?; 164 | Ok(toml::from_str(&content)?) 165 | } else { 166 | let config_file: PathBuf = xdg_dirs.place_config_file("config.toml")?; 167 | let default = include_bytes!("../assets/default_config.toml"); 168 | write(config_file, default)?; 169 | Ok(toml::from_str(&String::from_utf8_lossy(default))?) 170 | } 171 | } 172 | } 173 | 174 | #[derive(Debug, Serialize, Deserialize)] 175 | pub struct HistoryEntry { 176 | pub name: String, 177 | pub value: String, 178 | pub num_used: usize, 179 | } 180 | 181 | #[derive(Debug)] 182 | pub struct History { 183 | entries: Vec, 184 | path: PathBuf, 185 | } 186 | 187 | impl Default for History { 188 | fn default() -> Self { 189 | let xdg_dirs = BaseDirectories::with_prefix("kickoff"); 190 | Self { 191 | entries: Vec::new(), 192 | path: xdg_dirs 193 | .place_cache_file("default.csv") 194 | .expect("Failed to place history file"), 195 | } 196 | } 197 | } 198 | 199 | impl History { 200 | pub const fn as_vec(&self) -> &Vec { 201 | &self.entries 202 | } 203 | 204 | pub fn load(path: Option, decrease_interval: u64) -> Result { 205 | let history_path = if let Some(path) = path { 206 | path 207 | } else { 208 | let xdg_dirs = BaseDirectories::with_prefix("kickoff"); 209 | if let Some(path) = xdg_dirs.find_cache_file("default.csv") { 210 | path 211 | } else { 212 | return Ok(Self { 213 | entries: Vec::new(), 214 | path: xdg_dirs.place_cache_file("default.csv")?, 215 | }); 216 | } 217 | }; 218 | 219 | let mut res = Self { 220 | entries: Vec::new(), 221 | path: history_path.clone(), 222 | }; 223 | 224 | if history_path.exists() { 225 | let last_modified = history_path.metadata()?.modified()?; 226 | let interval_diff = if decrease_interval > 0 { 227 | SystemTime::now() 228 | .duration_since(SystemTime::UNIX_EPOCH) 229 | .unwrap() 230 | .as_secs() 231 | / (3600 * decrease_interval) 232 | - last_modified 233 | .duration_since(SystemTime::UNIX_EPOCH) 234 | .unwrap() 235 | .as_secs() 236 | / (3600 * decrease_interval) 237 | } else { 238 | 0 239 | }; 240 | 241 | let mut rdr = csv::Reader::from_path(history_path).unwrap(); 242 | for result in rdr.deserialize() { 243 | let mut record: HistoryEntry = result?; 244 | record.num_used = record.num_used.saturating_sub(interval_diff as usize); 245 | if record.num_used > 0 { 246 | res.entries.push(record); 247 | } 248 | } 249 | } else { 250 | info!("History file does not exists, will be created on saving"); 251 | } 252 | 253 | Ok(res) 254 | } 255 | 256 | pub fn inc(&mut self, element: &Element) { 257 | if let Some(entry) = self.entries.iter_mut().find(|x| x.name == element.name) { 258 | entry.num_used += 1; 259 | entry.value.clone_from(&element.value); 260 | } else { 261 | self.entries.push(HistoryEntry { 262 | name: element.name.clone(), 263 | value: element.value.clone(), 264 | num_used: 1, 265 | }); 266 | } 267 | } 268 | 269 | pub fn save(&self) -> Result<(), std::io::Error> { 270 | let mut wtr = csv::Writer::from_path(&self.path)?; 271 | for entry in &self.entries { 272 | wtr.serialize(entry)?; 273 | } 274 | wtr.flush()?; 275 | 276 | Ok(()) 277 | } 278 | } 279 | -------------------------------------------------------------------------------- /src/selection.rs: -------------------------------------------------------------------------------- 1 | use crate::config::{self, History}; 2 | use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; 3 | use log::warn; 4 | use std::fs::File; 5 | use std::{ 6 | cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd}, 7 | io::{BufRead, BufReader}, 8 | path::PathBuf, 9 | }; 10 | use std::{env, os::unix::fs::PermissionsExt}; 11 | use tokio::{ 12 | io::{self, AsyncBufReadExt}, 13 | task::{spawn, spawn_blocking}, 14 | }; 15 | 16 | #[derive(Eq, PartialEq, Debug, Clone)] 17 | pub struct Element { 18 | pub name: String, 19 | pub value: String, 20 | pub base_score: usize, 21 | } 22 | 23 | impl Ord for Element { 24 | fn cmp(&self, other: &Self) -> Ordering { 25 | match other.base_score.cmp(&self.base_score) { 26 | Ordering::Equal => self.name.cmp(&other.name), 27 | e => e, 28 | } 29 | } 30 | } 31 | 32 | impl PartialOrd for Element { 33 | fn partial_cmp(&self, other: &Self) -> Option { 34 | Some(self.cmp(other)) 35 | } 36 | } 37 | 38 | #[derive(Debug, Default)] 39 | pub struct ElementList { 40 | inner: Vec, 41 | } 42 | 43 | impl ElementList { 44 | pub fn merge_history(&mut self, history: &History) { 45 | for entry in history.as_vec() { 46 | if let Some(elem) = self.inner.iter_mut().find(|x| x.name == entry.name) { 47 | elem.base_score = entry.num_used; 48 | } else { 49 | self.inner.push(Element { 50 | name: entry.name.clone(), 51 | value: entry.value.clone(), 52 | base_score: entry.num_used, 53 | }); 54 | } 55 | } 56 | } 57 | 58 | pub fn sort_score(&mut self) { 59 | self.inner.sort_by(|a, b| b.base_score.cmp(&a.base_score)); 60 | } 61 | 62 | pub fn search(&self, pattern: &str) -> Vec<&Element> { 63 | let matcher = SkimMatcherV2::default(); 64 | let mut executables = self 65 | .inner 66 | .iter() 67 | .map(|x| { 68 | ( 69 | matcher 70 | .fuzzy_match(&x.name, pattern) 71 | .map(|score| score + x.base_score as i64), 72 | x, 73 | ) 74 | }) 75 | .filter(|x| x.0.is_some()) 76 | .collect::, &Element)>>(); 77 | executables.sort_by(|a, b| b.0.unwrap_or(0).cmp(&a.0.unwrap_or(0))); 78 | executables.into_iter().map(|x| x.1).collect() 79 | } 80 | 81 | pub fn as_ref_vec(&self) -> Vec<&Element> { 82 | self.inner.iter().collect() 83 | } 84 | } 85 | 86 | #[derive(Debug, Default)] 87 | pub struct ElementListBuilder { 88 | path_config: config::SearchConfig, 89 | from_path: bool, 90 | from_stdin: bool, 91 | from_file: Vec, 92 | } 93 | 94 | impl ElementListBuilder { 95 | pub fn new() -> Self { 96 | Self::default() 97 | } 98 | 99 | pub fn add_path(&mut self, config: config::SearchConfig) { 100 | self.from_path = true; 101 | self.path_config = config; 102 | } 103 | pub fn add_files(&mut self, files: &[PathBuf]) { 104 | self.from_file = files.to_vec(); 105 | } 106 | pub fn add_stdin(&mut self) { 107 | self.from_stdin = true; 108 | } 109 | 110 | pub async fn build(&self) -> Result { 111 | let mut fut = Vec::new(); 112 | if self.from_stdin { 113 | fut.push(spawn(Self::build_stdin())); 114 | } 115 | if !self.from_file.is_empty() { 116 | let files = self.from_file.clone(); 117 | fut.push(spawn_blocking(move || Self::build_files(&files))); 118 | } 119 | if self.from_path { 120 | let show_hidden = self.path_config.show_hidden_files; 121 | fut.push(spawn_blocking(move || Self::build_path(show_hidden))); 122 | } 123 | 124 | let finished = futures::future::join_all(fut).await; 125 | 126 | let mut res = Vec::new(); 127 | for elements in finished { 128 | let mut elements = elements??; 129 | res.append(&mut elements); 130 | } 131 | 132 | Ok(ElementList { inner: res }) 133 | } 134 | 135 | fn build_files(files: &[PathBuf]) -> Result, std::io::Error> { 136 | let mut res = Vec::new(); 137 | for file in files { 138 | let mut reader = BufReader::new(File::open(file)?); 139 | let mut buf = String::new(); 140 | let mut base_score = 0; 141 | 142 | while reader.read_line(&mut buf)? > 0 { 143 | let kv_pair = match parse_line(&buf) { 144 | None => continue, 145 | Some(res) => res, 146 | }; 147 | match kv_pair { 148 | ("%base_score", Some(value)) => { 149 | if let Ok(value) = value.parse::() { 150 | base_score = value; 151 | } 152 | } 153 | (key, Some(value)) => res.push(Element { 154 | name: key.to_string(), 155 | value: value.to_string(), 156 | base_score, 157 | }), 158 | ("", None) => {} // Empty Line 159 | (key, None) => res.push(Element { 160 | name: key.to_string(), 161 | value: key.to_string(), 162 | base_score, 163 | }), 164 | } 165 | 166 | buf.clear(); 167 | } 168 | } 169 | 170 | Ok(res) 171 | } 172 | 173 | fn build_path(show_hidden: bool) -> Result, std::io::Error> { 174 | let var = env::var("PATH").unwrap(); 175 | 176 | let mut res: Vec = Vec::new(); 177 | 178 | let paths_iter = env::split_paths(&var); 179 | let dirs_iter = paths_iter.filter_map(|path| std::fs::read_dir(path).ok()); 180 | 181 | for dir in dirs_iter { 182 | dir.filter_map(Result::ok).for_each(|file| { 183 | if !show_hidden 184 | && file 185 | .file_name() 186 | .to_str() 187 | .is_some_and(|name| name.starts_with('.')) 188 | { 189 | return; 190 | } 191 | if let Ok(metadata) = file.metadata() { 192 | if !metadata.is_dir() && metadata.permissions().mode() & 0o111 != 0 { 193 | let name = file.file_name().to_str().unwrap().to_string(); 194 | res.push(Element { 195 | value: name.clone(), 196 | name, 197 | base_score: 0, 198 | }); 199 | } 200 | } 201 | }); 202 | } 203 | 204 | res.sort(); 205 | res.dedup_by(|a, b| a.name == b.name); 206 | 207 | Ok(res) 208 | } 209 | 210 | async fn build_stdin() -> Result, std::io::Error> { 211 | let stdin = io::stdin(); 212 | let reader = io::BufReader::new(stdin); 213 | let mut lines = reader.lines(); 214 | let mut res = Vec::new(); 215 | let mut base_score = 0; 216 | 217 | while let Some(line) = lines.next_line().await? { 218 | let kv_pair = match parse_line(&line) { 219 | None => continue, 220 | Some(res) => res, 221 | }; 222 | match kv_pair { 223 | ("%base_score", Some(value)) => { 224 | if let Ok(value) = value.parse::() { 225 | base_score = value; 226 | } 227 | } 228 | (key, Some(value)) => res.push(Element { 229 | name: key.to_string(), 230 | value: value.to_string(), 231 | base_score, 232 | }), 233 | ("", None) => {} // Empty Line 234 | (key, None) => res.push(Element { 235 | name: key.to_string(), 236 | value: key.to_string(), 237 | base_score, 238 | }), 239 | } 240 | } 241 | 242 | Ok(res) 243 | } 244 | } 245 | 246 | #[allow(clippy::type_complexity)] 247 | fn parse_line(input: &str) -> Option<(&str, Option<&str>)> { 248 | let input = input.trim(); 249 | let parts = input.splitn(2, '=').map(str::trim).collect::>(); 250 | 251 | if parts.is_empty() { 252 | warn!("Failed to pares line: {input}"); 253 | None 254 | } else { 255 | Some((parts.first().unwrap(), parts.get(1).copied())) 256 | } 257 | } 258 | 259 | #[cfg(test)] 260 | mod tests { 261 | use super::*; 262 | 263 | #[test] 264 | fn parse_line_test() { 265 | assert_eq!(parse_line("foobar"), Some(("foobar", None))); 266 | assert_eq!(parse_line("foo=bar"), Some(("foo", Some("bar")))); 267 | assert_eq!( 268 | parse_line("foo=bar\"baz\""), 269 | Some(("foo", Some("bar\"baz\""))) 270 | ); 271 | assert_eq!( 272 | parse_line( 273 | r#"Desktop: Firefox Developer Edition - New Window=/usr/lib/firefox-developer-edition/firefox --class="firefoxdeveloperedition" --new-window %u"# 274 | ), 275 | Some(( 276 | "Desktop: Firefox Developer Edition - New Window", 277 | Some( 278 | r#"/usr/lib/firefox-developer-edition/firefox --class="firefoxdeveloperedition" --new-window %u"# 279 | ) 280 | )) 281 | ); 282 | } 283 | } 284 | -------------------------------------------------------------------------------- /src/app.rs: -------------------------------------------------------------------------------- 1 | use std::time::{Duration, Instant}; 2 | use std::{cmp, process}; 3 | 4 | use crate::config::{Config, History}; 5 | use crate::font::Font; 6 | use crate::selection::{Element, ElementList}; 7 | use crate::Args; 8 | use image::{ImageBuffer, RgbaImage}; 9 | use log::{debug, error}; 10 | use nix::{ 11 | sys::wait::{waitpid, WaitPidFlag, WaitStatus}, 12 | unistd::{fork, ForkResult}, 13 | }; 14 | use notify_rust::Notification; 15 | 16 | pub struct App { 17 | pub config: Config, 18 | pub select_index: usize, 19 | pub select_input: bool, 20 | pub all_entries: ElementList, 21 | pub query: String, 22 | pub font: Font, 23 | pub history: Option, 24 | pub last_search_result: Vec, 25 | pub args: Args, 26 | } 27 | 28 | impl App { 29 | pub fn new( 30 | args: Args, 31 | config: Config, 32 | all_entries: ElementList, 33 | font: Font, 34 | history: Option, 35 | ) -> Self { 36 | let mut app = Self { 37 | args, 38 | config, 39 | font, 40 | select_index: 0, 41 | select_input: false, 42 | history, 43 | all_entries, 44 | query: String::new(), 45 | last_search_result: Vec::new(), 46 | }; 47 | app.search(); 48 | 49 | app 50 | } 51 | 52 | pub fn complete(&mut self) { 53 | if !self.select_input { 54 | let app = (*self 55 | .all_entries 56 | .as_ref_vec() 57 | .get(*self.last_search_result.get(self.select_index).unwrap()) 58 | .unwrap()) 59 | .clone(); 60 | if self.query == app.name { 61 | self.select_index = if self.select_index < self.last_search_result.len() - 1 { 62 | self.select_index + 1 63 | } else { 64 | self.select_index 65 | }; 66 | } 67 | self.query.clear(); 68 | self.query.push_str(&app.name); 69 | } 70 | } 71 | 72 | pub fn nav_up(&mut self, distance: usize) { 73 | if self.select_index > 0 { 74 | self.select_index = self.select_index.saturating_sub(distance); 75 | } else if !self.query.is_empty() { 76 | self.select_input = true; 77 | } 78 | } 79 | 80 | pub fn nav_down(&mut self, distance: usize) { 81 | if self.select_input && !self.last_search_result.is_empty() { 82 | self.select_input = false; 83 | self.select_index = 0; 84 | } else if !self.last_search_result.is_empty() 85 | && self.select_index < self.last_search_result.len() - distance 86 | { 87 | self.select_index += distance; 88 | } 89 | } 90 | 91 | pub fn delete(&mut self) { 92 | self.query.pop(); 93 | self.search(); 94 | } 95 | 96 | pub fn delete_word(&mut self) { 97 | self.query.pop(); 98 | loop { 99 | let removed_char = self.query.pop(); 100 | if removed_char.unwrap_or(' ') == ' ' { 101 | break; 102 | } 103 | } 104 | self.search(); 105 | } 106 | 107 | pub fn execute(&mut self) { 108 | let element = if self.select_input { 109 | Element { 110 | name: self.query.to_string(), 111 | value: self.query.to_string(), 112 | base_score: 0, 113 | } 114 | } else { 115 | (*self 116 | .all_entries 117 | .as_ref_vec() 118 | .get(*self.last_search_result.get(self.select_index).unwrap()) 119 | .unwrap()) 120 | .clone() 121 | }; 122 | if self.args.stdout { 123 | print!("{}", element.value); 124 | if let Some(mut history) = self.history.take() { 125 | history.inc(&element); 126 | history.save().unwrap(); 127 | } 128 | } else { 129 | execute(&element, self.history.take()); 130 | } 131 | } 132 | 133 | pub fn insert(&mut self, input: &str) { 134 | self.query.push_str(input); 135 | self.search(); 136 | } 137 | 138 | pub fn search(&mut self) { 139 | self.last_search_result = Vec::new(); 140 | let search_results = self.all_entries.search(&self.query); 141 | 142 | self.select_input = false; 143 | self.select_index = 0; 144 | if search_results.is_empty() { 145 | self.select_input = true; 146 | } 147 | 148 | // Build list of indices to search results 149 | let all_entries = self.all_entries.as_ref_vec(); 150 | for entry in search_results { 151 | let index = all_entries.iter().position(|x| x == &entry); 152 | if let Some(i) = index { 153 | self.last_search_result.push(i); 154 | } 155 | } 156 | } 157 | 158 | pub fn draw(&mut self, width: u32, height: u32, scale: i32) -> RgbaImage { 159 | let frame_draw_start = Instant::now(); 160 | let search_results: Vec<&Element> = self 161 | .last_search_result 162 | .iter() 163 | .map(|index| *self.all_entries.as_ref_vec().get(*index).unwrap()) 164 | .collect(); 165 | 166 | self.font.set_scale(scale); 167 | let padding = self.config.padding * scale as u32; 168 | let font_size = self.config.font_size * scale as f32; 169 | 170 | let mut img = 171 | ImageBuffer::from_pixel(width, height, self.config.colors.background.to_rgba()); 172 | let prompt = match &self.args.prompt { 173 | Some(prompt) => prompt, 174 | None => &self.config.prompt, 175 | }; 176 | let prompt_width = if prompt.is_empty() { 177 | 0 178 | } else { 179 | let (width, _) = self.font.render( 180 | prompt, 181 | &self.config.colors.prompt, 182 | &mut img, 183 | padding, 184 | padding, 185 | None, 186 | ); 187 | width + (font_size * 0.2) as u32 188 | }; 189 | 190 | if !self.query.is_empty() { 191 | let color = if self.select_input { 192 | &self.config.colors.text_selected 193 | } else { 194 | &self.config.colors.text_query 195 | }; 196 | self.font.render( 197 | &self.query, 198 | color, 199 | &mut img, 200 | padding + prompt_width, 201 | padding, 202 | None, 203 | ); 204 | } 205 | 206 | let spacer = (1.5 * font_size) as u32; 207 | let max_entries = ((height.saturating_sub(2 * padding).saturating_sub(spacer)) as f32 208 | / (font_size * 1.2)) as usize; 209 | let offset = if self.select_index > (max_entries / 2) { 210 | self.select_index - max_entries / 2 211 | } else { 212 | 0 213 | }; 214 | 215 | for (i, matched) in search_results 216 | .iter() 217 | .enumerate() 218 | .take(cmp::min(max_entries + offset, search_results.len())) 219 | .skip(offset) 220 | { 221 | let color = if i == self.select_index && !self.select_input { 222 | &self.config.colors.text_selected 223 | } else { 224 | &self.config.colors.text 225 | }; 226 | self.font.render( 227 | &matched.name, 228 | color, 229 | &mut img, 230 | padding, 231 | padding + spacer + (i - offset) as u32 * (font_size * 1.2) as u32, 232 | Some((width - (padding * 2)) as usize), 233 | ); 234 | } 235 | 236 | let elapsed = frame_draw_start.elapsed(); 237 | debug!("frame time: {:.2?}", elapsed); 238 | 239 | img 240 | } 241 | } 242 | 243 | fn execute(elem: &Element, history: Option) { 244 | match unsafe { fork() } { 245 | Ok(ForkResult::Parent { child }) => { 246 | // We can't make that to long, since for some reason, even if this would be after a fork and the main programm exits, 247 | // wayland keeps the window alive 248 | std::thread::sleep(Duration::new(0, 100_000_000)); 249 | match waitpid(child, Some(WaitPidFlag::WNOHANG)) { 250 | Ok(WaitStatus::StillAlive | WaitStatus::Exited(_, 0)) => { 251 | if let Some(mut history) = history { 252 | history.inc(elem); 253 | match history.save() { 254 | Ok(()) => {} 255 | Err(e) => { 256 | error!("{e}"); 257 | } 258 | }; 259 | } 260 | } 261 | Ok(_) => { 262 | /* Every non 0 statuscode holds no information since it's 263 | origin can be the started application or a file not found error. 264 | In either case the error has already been logged and does not 265 | need to be handled here. */ 266 | } 267 | Err(err) => error!("{err}"), 268 | } 269 | } 270 | 271 | Ok(ForkResult::Child) => { 272 | let err = exec::Command::new("sh").args(&["-c", &elem.value]).exec(); 273 | 274 | // Won't be executed when exec was successful 275 | error!("{err}"); 276 | 277 | Notification::new() 278 | .summary("Kickoff") 279 | .body(&format!("{err}")) 280 | .timeout(5000) 281 | .show() 282 | .unwrap(); 283 | process::exit(2); 284 | } 285 | Err(e) => error!("{e}"), 286 | } 287 | } 288 | -------------------------------------------------------------------------------- /src/gui.rs: -------------------------------------------------------------------------------- 1 | use crate::{keybinds::Keybindings, App}; 2 | use image::Pixel; 3 | use log::{debug, error}; 4 | use smithay_client_toolkit::{ 5 | compositor::{CompositorHandler, CompositorState}, 6 | delegate_compositor, delegate_keyboard, delegate_layer, delegate_output, delegate_pointer, 7 | delegate_registry, delegate_seat, delegate_shm, 8 | output::{OutputHandler, OutputState}, 9 | reexports::{ 10 | calloop::{EventLoop, LoopHandle}, 11 | calloop_wayland_source::WaylandSource, 12 | }, 13 | registry::{ProvidesRegistryState, RegistryState}, 14 | registry_handlers, 15 | seat::{ 16 | keyboard::{KeyEvent, KeyboardHandler, Modifiers}, 17 | pointer::{PointerEvent, PointerEventKind, PointerHandler}, 18 | Capability, SeatHandler, SeatState, 19 | }, 20 | shell::{ 21 | wlr_layer::{ 22 | Anchor, KeyboardInteractivity, Layer, LayerShell, LayerShellHandler, LayerSurface, 23 | LayerSurfaceConfigure, 24 | }, 25 | WaylandSurface, 26 | }, 27 | shm::{slot::SlotPool, Shm, ShmHandler}, 28 | }; 29 | use std::{ 30 | io::{BufWriter, Read, Write}, 31 | time::Duration, 32 | }; 33 | use wayland_client::{ 34 | globals::registry_queue_init, 35 | protocol::{wl_keyboard, wl_output, wl_pointer, wl_seat, wl_shm, wl_surface}, 36 | Connection, QueueHandle, 37 | }; 38 | use wl_clipboard_rs::paste::{get_contents, ClipboardType, Error, MimeType, Seat}; 39 | 40 | #[derive(Clone)] 41 | pub enum Action { 42 | Execute, 43 | Exit, 44 | Complete, 45 | NavUp, 46 | NavDown, 47 | Delete, 48 | DeleteWord, 49 | Paste, 50 | Insert(String), 51 | } 52 | 53 | pub fn run(app: App) { 54 | let conn = Connection::connect_to_env().unwrap(); 55 | 56 | let (globals, event_queue) = registry_queue_init(&conn).unwrap(); 57 | let qh = event_queue.handle(); 58 | let mut event_loop: EventLoop = 59 | EventLoop::try_new().expect("Failed to initialize event loop"); 60 | let loop_handle = event_loop.handle(); 61 | WaylandSource::new(conn, event_queue) 62 | .insert(loop_handle) 63 | .unwrap(); 64 | 65 | let compositor = CompositorState::bind(&globals, &qh).expect("wl_compositor is not available"); 66 | let layer_shell = LayerShell::bind(&globals, &qh).expect("layer shell is not available"); 67 | let shm = Shm::bind(&globals, &qh).expect("wl_shm is not available"); 68 | 69 | let surface = compositor.create_surface(&qh); 70 | 71 | let layer = layer_shell.create_layer_surface(&qh, surface, Layer::Top, Some("kickoff"), None); 72 | 73 | layer.set_anchor(Anchor::all()); 74 | layer.set_keyboard_interactivity(KeyboardInteractivity::Exclusive); 75 | 76 | layer.commit(); 77 | 78 | let pool = SlotPool::new(256 * 256 * 4, &shm).expect("Failed to create pool"); 79 | 80 | let mut gui_layer = GuiLayer { 81 | registry_state: RegistryState::new(&globals), 82 | seat_state: SeatState::new(&globals, &qh), 83 | output_state: OutputState::new(&globals, &qh), 84 | shm, 85 | 86 | exit: false, 87 | first_configure: true, 88 | pool, 89 | width: 256, 90 | height: 256, 91 | layer, 92 | keyboard: None, 93 | pointer: None, 94 | scale_factor: 1, 95 | modifiers: Modifiers::default(), 96 | keybindings: Keybindings::from(app.config.keybindings.clone()), 97 | app, 98 | next_action: None, 99 | loop_handle: event_loop.handle(), 100 | }; 101 | 102 | loop { 103 | event_loop 104 | .dispatch(Duration::from_millis(50), &mut gui_layer) 105 | .unwrap(); 106 | match &gui_layer.next_action.take() { 107 | Some(Action::Exit) => gui_layer.exit = true, 108 | Some(Action::Complete) => gui_layer.app.complete(), 109 | Some(Action::Delete) => gui_layer.app.delete(), 110 | Some(Action::DeleteWord) => gui_layer.app.delete_word(), 111 | Some(Action::NavUp) => gui_layer.app.nav_up(1), 112 | Some(Action::NavDown) => gui_layer.app.nav_down(1), 113 | Some(Action::Insert(s)) => gui_layer.app.insert(s), 114 | Some(Action::Execute) => { 115 | gui_layer.app.execute(); 116 | gui_layer.exit = true; 117 | } 118 | Some(Action::Paste) => { 119 | let result = 120 | get_contents(ClipboardType::Regular, Seat::Unspecified, MimeType::Text); 121 | match result { 122 | Ok((mut pipe, _)) => { 123 | let mut contents = vec![]; 124 | pipe.read_to_end(&mut contents).unwrap(); 125 | let input = String::from_utf8(contents).unwrap(); 126 | gui_layer.app.insert(&input); 127 | } 128 | Err(Error::NoSeats | Error::ClipboardEmpty | Error::NoMimeType) => {} 129 | Err(e) => error!("{e}"), 130 | } 131 | } 132 | _ => {} 133 | } 134 | 135 | if gui_layer.exit { 136 | debug!("exiting kickoff"); 137 | break; 138 | } 139 | } 140 | } 141 | 142 | struct GuiLayer { 143 | registry_state: RegistryState, 144 | seat_state: SeatState, 145 | output_state: OutputState, 146 | shm: Shm, 147 | 148 | exit: bool, 149 | first_configure: bool, 150 | pool: SlotPool, 151 | width: u32, 152 | height: u32, 153 | layer: LayerSurface, 154 | keyboard: Option, 155 | pointer: Option, 156 | scale_factor: i32, 157 | modifiers: Modifiers, 158 | app: App, 159 | next_action: Option, 160 | keybindings: Keybindings, 161 | loop_handle: LoopHandle<'static, GuiLayer>, 162 | } 163 | 164 | impl CompositorHandler for GuiLayer { 165 | fn scale_factor_changed( 166 | &mut self, 167 | _conn: &Connection, 168 | _qh: &QueueHandle, 169 | _surface: &wl_surface::WlSurface, 170 | new_factor: i32, 171 | ) { 172 | self.scale_factor = new_factor; 173 | self.layer.set_buffer_scale(new_factor as u32).unwrap(); 174 | } 175 | 176 | fn frame( 177 | &mut self, 178 | _conn: &Connection, 179 | qh: &QueueHandle, 180 | _surface: &wl_surface::WlSurface, 181 | _time: u32, 182 | ) { 183 | self.draw(qh); 184 | } 185 | 186 | fn transform_changed( 187 | &mut self, 188 | _conn: &Connection, 189 | _qh: &QueueHandle, 190 | _surface: &wl_surface::WlSurface, 191 | _new_transform: wl_output::Transform, 192 | ) { 193 | } 194 | 195 | fn surface_enter( 196 | &mut self, 197 | _: &Connection, 198 | _: &QueueHandle, 199 | _: &wl_surface::WlSurface, 200 | _: &wl_output::WlOutput, 201 | ) { 202 | } 203 | 204 | fn surface_leave( 205 | &mut self, 206 | _: &Connection, 207 | _: &QueueHandle, 208 | _: &wl_surface::WlSurface, 209 | _: &wl_output::WlOutput, 210 | ) { 211 | self.next_action = Some(Action::Exit); 212 | } 213 | } 214 | 215 | impl OutputHandler for GuiLayer { 216 | fn output_state(&mut self) -> &mut OutputState { 217 | &mut self.output_state 218 | } 219 | 220 | fn new_output( 221 | &mut self, 222 | _conn: &Connection, 223 | _qh: &QueueHandle, 224 | _output: wl_output::WlOutput, 225 | ) { 226 | } 227 | 228 | fn update_output( 229 | &mut self, 230 | _conn: &Connection, 231 | _qh: &QueueHandle, 232 | _output: wl_output::WlOutput, 233 | ) { 234 | } 235 | 236 | fn output_destroyed( 237 | &mut self, 238 | _conn: &Connection, 239 | _qh: &QueueHandle, 240 | _output: wl_output::WlOutput, 241 | ) { 242 | } 243 | } 244 | 245 | impl LayerShellHandler for GuiLayer { 246 | fn closed(&mut self, _conn: &Connection, _qh: &QueueHandle, _layer: &LayerSurface) { 247 | self.exit = true; 248 | } 249 | 250 | fn configure( 251 | &mut self, 252 | _conn: &Connection, 253 | qh: &QueueHandle, 254 | _layer: &LayerSurface, 255 | configure: LayerSurfaceConfigure, 256 | _serial: u32, 257 | ) { 258 | if configure.new_size.0 == 0 || configure.new_size.1 == 0 { 259 | self.width = 256; 260 | self.height = 256; 261 | } else { 262 | self.width = configure.new_size.0; 263 | self.height = configure.new_size.1; 264 | } 265 | 266 | // Initiate the first draw. 267 | if self.first_configure { 268 | self.first_configure = false; 269 | self.draw(qh); 270 | } 271 | } 272 | } 273 | 274 | impl SeatHandler for GuiLayer { 275 | fn seat_state(&mut self) -> &mut SeatState { 276 | &mut self.seat_state 277 | } 278 | 279 | fn new_seat(&mut self, _: &Connection, _: &QueueHandle, _: wl_seat::WlSeat) {} 280 | 281 | fn new_capability( 282 | &mut self, 283 | _conn: &Connection, 284 | qh: &QueueHandle, 285 | seat: wl_seat::WlSeat, 286 | capability: Capability, 287 | ) { 288 | if capability == Capability::Keyboard && self.keyboard.is_none() { 289 | debug!("Set keyboard capability"); 290 | let keyboard = self 291 | .seat_state 292 | .get_keyboard_with_repeat( 293 | qh, 294 | &seat, 295 | None, 296 | self.loop_handle.clone(), 297 | Box::new(|state, _wl_kbd, event| { 298 | if let Some(action) = state.keybindings.get(state.modifiers, event.keysym) { 299 | state.next_action = Some(action.clone()); 300 | } else if let Some(input) = event.utf8 { 301 | state.next_action = Some(Action::Insert(input)); 302 | } 303 | }), 304 | ) 305 | .expect("Failed to create keyboard"); 306 | self.keyboard = Some(keyboard); 307 | } 308 | 309 | if capability == Capability::Pointer && self.pointer.is_none() { 310 | debug!("Set pointer capability"); 311 | let pointer = self 312 | .seat_state 313 | .get_pointer(qh, &seat) 314 | .expect("Failed to create pointer"); 315 | self.pointer = Some(pointer); 316 | } 317 | } 318 | 319 | fn remove_capability( 320 | &mut self, 321 | _conn: &Connection, 322 | _: &QueueHandle, 323 | _: wl_seat::WlSeat, 324 | capability: Capability, 325 | ) { 326 | if capability == Capability::Keyboard && self.keyboard.is_some() { 327 | debug!("Unset keyboard capability"); 328 | self.keyboard.take().unwrap().release(); 329 | } 330 | 331 | if capability == Capability::Pointer && self.pointer.is_some() { 332 | debug!("Unset pointer capability"); 333 | self.pointer.take().unwrap().release(); 334 | } 335 | } 336 | 337 | fn remove_seat(&mut self, _: &Connection, _: &QueueHandle, _: wl_seat::WlSeat) {} 338 | } 339 | 340 | impl KeyboardHandler for GuiLayer { 341 | fn enter( 342 | &mut self, 343 | _: &Connection, 344 | _: &QueueHandle, 345 | _: &wl_keyboard::WlKeyboard, 346 | _: &wl_surface::WlSurface, 347 | _: u32, 348 | _: &[u32], 349 | _keysyms: &[smithay_client_toolkit::seat::keyboard::Keysym], 350 | ) { 351 | } 352 | 353 | fn leave( 354 | &mut self, 355 | _: &Connection, 356 | _: &QueueHandle, 357 | _: &wl_keyboard::WlKeyboard, 358 | _: &wl_surface::WlSurface, 359 | _: u32, 360 | ) { 361 | self.next_action = Some(Action::Exit); 362 | } 363 | 364 | fn press_key( 365 | &mut self, 366 | _conn: &Connection, 367 | _qh: &QueueHandle, 368 | _: &wl_keyboard::WlKeyboard, 369 | _: u32, 370 | event: KeyEvent, 371 | ) { 372 | debug!("Key press: {event:?}"); 373 | if let Some(action) = self.keybindings.get(self.modifiers, event.keysym) { 374 | self.next_action = Some(action.clone()); 375 | } else if let Some(input) = event.utf8 { 376 | self.next_action = Some(Action::Insert(input)); 377 | } 378 | } 379 | 380 | fn release_key( 381 | &mut self, 382 | _: &Connection, 383 | _: &QueueHandle, 384 | _: &wl_keyboard::WlKeyboard, 385 | _: u32, 386 | event: KeyEvent, 387 | ) { 388 | debug!("Key release: {event:?}"); 389 | } 390 | 391 | fn update_modifiers( 392 | &mut self, 393 | _: &Connection, 394 | _: &QueueHandle, 395 | _: &wl_keyboard::WlKeyboard, 396 | _serial: u32, 397 | modifiers: Modifiers, 398 | _: u32, 399 | ) { 400 | debug!("Update modifiers: {modifiers:?}"); 401 | self.modifiers = modifiers; 402 | } 403 | } 404 | 405 | impl PointerHandler for GuiLayer { 406 | fn pointer_frame( 407 | &mut self, 408 | _conn: &Connection, 409 | _qh: &QueueHandle, 410 | _pointer: &wl_pointer::WlPointer, 411 | events: &[PointerEvent], 412 | ) { 413 | use PointerEventKind::Press; 414 | for event in events { 415 | // Ignore events for other surfaces 416 | if &event.surface != self.layer.wl_surface() { 417 | continue; 418 | } 419 | 420 | if let Press { button: 274, .. } = event.kind { 421 | let result = 422 | get_contents(ClipboardType::Primary, Seat::Unspecified, MimeType::Text); 423 | match result { 424 | Ok((mut pipe, _)) => { 425 | let mut contents = vec![]; 426 | pipe.read_to_end(&mut contents).unwrap(); 427 | let input = String::from_utf8(contents).unwrap(); 428 | self.next_action = Some(Action::Insert(input)); 429 | } 430 | Err(Error::NoSeats | Error::ClipboardEmpty | Error::NoMimeType) => {} 431 | Err(e) => error!("{e}"), 432 | } 433 | } 434 | } 435 | } 436 | } 437 | 438 | impl ShmHandler for GuiLayer { 439 | fn shm_state(&mut self) -> &mut Shm { 440 | &mut self.shm 441 | } 442 | } 443 | 444 | impl GuiLayer { 445 | pub fn draw(&mut self, qh: &QueueHandle) { 446 | let width = self.width * self.scale_factor as u32; 447 | let height = self.height * self.scale_factor as u32; 448 | let stride = width as i32 * 4; 449 | 450 | let (buffer, canvas) = self 451 | .pool 452 | .create_buffer( 453 | width as i32, 454 | height as i32, 455 | stride, 456 | wl_shm::Format::Argb8888, 457 | ) 458 | .expect("create buffer"); 459 | 460 | let mut image = self.app.draw(width, height, self.scale_factor); 461 | image.pixels_mut().for_each(|pixel| { 462 | let channels = pixel.channels_mut(); 463 | channels.swap(0, 2); 464 | }); 465 | 466 | // Draw to the window: 467 | let mut writer = BufWriter::new(&mut *canvas); 468 | writer.write_all(image.as_raw()).unwrap(); 469 | writer.flush().unwrap(); 470 | 471 | // Damage the entire window 472 | self.layer 473 | .wl_surface() 474 | .damage_buffer(0, 0, width as i32, height as i32); 475 | 476 | // Request our next frame 477 | self.layer 478 | .wl_surface() 479 | .frame(qh, self.layer.wl_surface().clone()); 480 | 481 | // Attach and commit to present. 482 | buffer 483 | .attach_to(self.layer.wl_surface()) 484 | .expect("buffer attach"); 485 | self.layer.commit(); 486 | } 487 | } 488 | 489 | delegate_compositor!(GuiLayer); 490 | delegate_output!(GuiLayer); 491 | delegate_shm!(GuiLayer); 492 | 493 | delegate_seat!(GuiLayer); 494 | delegate_keyboard!(GuiLayer); 495 | delegate_pointer!(GuiLayer); 496 | 497 | delegate_layer!(GuiLayer); 498 | 499 | delegate_registry!(GuiLayer); 500 | 501 | impl ProvidesRegistryState for GuiLayer { 502 | fn registry(&mut self) -> &mut RegistryState { 503 | &mut self.registry_state 504 | } 505 | registry_handlers![OutputState, SeatState]; 506 | } 507 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 729 | -------------------------------------------------------------------------------- /assets/logo_social.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 801 | --------------------------------------------------------------------------------