diff --git a/Cargo.toml b/Cargo.toml index 62ade99..5b0a6c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,17 +1,18 @@ [package] -name = "" +name = "tabset" version = "0.1.0" authors = ["Evan Pratten "] edition = "2018" -description = "" -documentation = "https://docs.rs/" +description = "A Linux drawing tablet configuration tool" readme = "README.md" -homepage = "https://github.com/ewpratten/" -repository = "https://github.com/ewpratten/" +homepage = "https://github.com/ewpratten/tabset" +repository = "https://github.com/ewpratten/tabset" license = "GPL-3.0" -keywords = [] +keywords = ["configuration", "tablet", "wacom", "x11"] categories = [] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [dependencies] +clap = { versions = "2.33", features = ["color"] } +colored = "2.0.0" +directories = "4.0.1" \ No newline at end of file diff --git a/README.md b/README.md index ee77e0d..23c6ad3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# -[![Crates.io](https://img.shields.io/crates/v/)](https://crates.io/crates/) -[![Docs.rs](https://docs.rs//badge.svg)](https://docs.rs/) -[![Build](https://github.com/Ewpratten//actions/workflows/build.yml/badge.svg)](https://github.com/Ewpratten//actions/workflows/build.yml) -[![Clippy](https://github.com/Ewpratten//actions/workflows/clippy.yml/badge.svg)](https://github.com/Ewpratten//actions/workflows/clippy.yml) -[![Audit](https://github.com/Ewpratten//actions/workflows/audit.yml/badge.svg)](https://github.com/Ewpratten//actions/workflows/audit.yml) +# tabset +[![Crates.io](https://img.shields.io/crates/v/tabset)](https://crates.io/crates/tabset) +[![Docs.rs](https://docs.rs/tabset/badge.svg)](https://docs.rs/tabset) +[![Build](https://github.com/Ewpratten/tabset/actions/workflows/build.yml/badge.svg)](https://github.com/Ewpratten/tabset/actions/workflows/build.yml) +[![Clippy](https://github.com/Ewpratten/tabset/actions/workflows/clippy.yml/badge.svg)](https://github.com/Ewpratten/tabset/actions/workflows/clippy.yml) +[![Audit](https://github.com/Ewpratten/tabset/actions/workflows/audit.yml/badge.svg)](https://github.com/Ewpratten/tabset/actions/workflows/audit.yml) repo description @@ -13,5 +13,7 @@ repo description This crate can be installed via `cargo` with: ```sh -cargo install +cargo install tabset ``` + +## Configuration \ No newline at end of file diff --git a/example_configs/devices/huion-kamvas-13/profiles/blender.sh b/example_configs/devices/huion-kamvas-13/profiles/blender.sh index fb3fb0c..2d54072 100644 --- a/example_configs/devices/huion-kamvas-13/profiles/blender.sh +++ b/example_configs/devices/huion-kamvas-13/profiles/blender.sh @@ -1,7 +1,18 @@ +# Top three buttons xsetwacom --set "Tablet Monitor Pad pad" Button 1 "key +ctrl +z -z -ctrl" xsetwacom --set "Tablet Monitor Pad pad" Button 2 "key +ctrl +tab -tab -ctrl" +xsetwacom --set "Tablet Monitor Pad pad" Button 3 "key x" + +# Middle two buttons xsetwacom --set "Tablet Monitor Pad pad" Button 8 "key shift" xsetwacom --set "Tablet Monitor Pad pad" Button 9 "key ctrl" + +# Bottom three buttons xsetwacom --set "Tablet Monitor Pad pad" Button 10 "key 1" xsetwacom --set "Tablet Monitor Pad pad" Button 11 "key 3" -xsetwacom --set "Tablet Monitor Pad pad" Button 12 "key 0" \ No newline at end of file +xsetwacom --set "Tablet Monitor Pad pad" Button 12 "key 0" + +# Pen buttons +xsetwacom set "Tablet Monitor stylus" "Button" "1" "button +1 " +xsetwacom set "Tablet Monitor stylus" "Button" "2" "button +2 " +xsetwacom set "Tablet Monitor stylus" "Button" "3" "button +3 " \ No newline at end of file diff --git a/src/commands/check.rs b/src/commands/check.rs new file mode 100644 index 0000000..6fa93c3 --- /dev/null +++ b/src/commands/check.rs @@ -0,0 +1,4 @@ + +pub fn check_tablet(tablet_name: &str) -> i32 { + todo!() +} \ No newline at end of file diff --git a/src/commands/list.rs b/src/commands/list.rs new file mode 100644 index 0000000..55c83e9 --- /dev/null +++ b/src/commands/list.rs @@ -0,0 +1,8 @@ +use crate::config::get_config_dir; + + +pub fn list_tablets(){ + + let config_dir = get_config_dir(); + +} \ No newline at end of file diff --git a/src/commands/mod.rs b/src/commands/mod.rs new file mode 100644 index 0000000..91cfdd5 --- /dev/null +++ b/src/commands/mod.rs @@ -0,0 +1,6 @@ +mod check; +mod list; +mod profile; +pub use check::check_tablet; +pub use list::list_tablets; +pub use profile::set_profile; \ No newline at end of file diff --git a/src/commands/profile.rs b/src/commands/profile.rs new file mode 100644 index 0000000..4630c1e --- /dev/null +++ b/src/commands/profile.rs @@ -0,0 +1,4 @@ + +pub fn set_profile(tablet_name: &str, profile_name: &str) { + todo!(); +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index f1b9f47..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,66 +0,0 @@ -#![doc = include_str!("../README.md")] -#![deny(unsafe_code)] -#![warn( - clippy::all, - clippy::await_holding_lock, - clippy::char_lit_as_u8, - clippy::checked_conversions, - clippy::dbg_macro, - clippy::debug_assert_with_mut_call, - clippy::doc_markdown, - clippy::empty_enum, - clippy::enum_glob_use, - clippy::exit, - clippy::expl_impl_clone_on_copy, - clippy::explicit_deref_methods, - clippy::explicit_into_iter_loop, - clippy::fallible_impl_from, - clippy::filter_map_next, - clippy::float_cmp_const, - clippy::fn_params_excessive_bools, - clippy::if_let_mutex, - clippy::implicit_clone, - clippy::imprecise_flops, - clippy::inefficient_to_string, - clippy::invalid_upcast_comparisons, - clippy::large_types_passed_by_value, - clippy::let_unit_value, - clippy::linkedlist, - clippy::lossy_float_literal, - clippy::macro_use_imports, - clippy::manual_ok_or, - clippy::map_err_ignore, - clippy::map_flatten, - clippy::map_unwrap_or, - clippy::match_on_vec_items, - clippy::match_same_arms, - clippy::match_wildcard_for_single_variants, - clippy::mem_forget, - clippy::mismatched_target_os, - clippy::mut_mut, - clippy::mutex_integer, - clippy::needless_borrow, - clippy::needless_continue, - clippy::option_option, - clippy::path_buf_push_overwrite, - clippy::ptr_as_ptr, - clippy::ref_option_ref, - clippy::rest_pat_in_fully_bound_structs, - clippy::same_functions_in_if_condition, - clippy::semicolon_if_nothing_returned, - clippy::string_add_assign, - clippy::string_add, - clippy::string_lit_as_bytes, - clippy::string_to_string, - clippy::todo, - clippy::trait_duplication_in_bounds, - clippy::unimplemented, - clippy::unnested_or_patterns, - clippy::unused_self, - clippy::useless_transmute, - clippy::verbose_file_reads, - clippy::zero_sized_map_values, - future_incompatible, - nonstandard_style, - rust_2018_idioms -)] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..c4775d8 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,133 @@ +#![deny(unsafe_code)] +#![warn( + clippy::all, + clippy::await_holding_lock, + clippy::char_lit_as_u8, + clippy::checked_conversions, + clippy::dbg_macro, + clippy::debug_assert_with_mut_call, + clippy::doc_markdown, + clippy::empty_enum, + clippy::enum_glob_use, + clippy::exit, + clippy::expl_impl_clone_on_copy, + clippy::explicit_deref_methods, + clippy::explicit_into_iter_loop, + clippy::fallible_impl_from, + clippy::filter_map_next, + clippy::float_cmp_const, + clippy::fn_params_excessive_bools, + clippy::if_let_mutex, + clippy::implicit_clone, + clippy::imprecise_flops, + clippy::inefficient_to_string, + clippy::invalid_upcast_comparisons, + clippy::large_types_passed_by_value, + clippy::let_unit_value, + clippy::linkedlist, + clippy::lossy_float_literal, + clippy::macro_use_imports, + clippy::manual_ok_or, + clippy::map_err_ignore, + clippy::map_flatten, + clippy::map_unwrap_or, + clippy::match_on_vec_items, + clippy::match_same_arms, + clippy::match_wildcard_for_single_variants, + clippy::mem_forget, + clippy::mismatched_target_os, + clippy::mut_mut, + clippy::mutex_integer, + clippy::needless_borrow, + clippy::needless_continue, + clippy::option_option, + clippy::path_buf_push_overwrite, + clippy::ptr_as_ptr, + clippy::ref_option_ref, + clippy::rest_pat_in_fully_bound_structs, + clippy::same_functions_in_if_condition, + clippy::semicolon_if_nothing_returned, + clippy::string_add_assign, + clippy::string_add, + clippy::string_lit_as_bytes, + clippy::string_to_string, + clippy::todo, + clippy::trait_duplication_in_bounds, + clippy::unimplemented, + clippy::unnested_or_patterns, + clippy::unused_self, + clippy::useless_transmute, + clippy::verbose_file_reads, + clippy::zero_sized_map_values, + future_incompatible, + nonstandard_style, + rust_2018_idioms +)] + +mod commands; +pub mod config; + +use clap::{ + crate_authors, crate_description, crate_name, crate_version, App, AppSettings, Arg, SubCommand, +}; +use commands::{check_tablet, list_tablets, set_profile}; + +fn main() { + // Handle the command line arguments + let matches = App::new(crate_name!()) + .author(crate_authors!()) + .about(crate_description!()) + .version(crate_version!()) + .setting(AppSettings::SubcommandRequiredElseHelp) + .subcommand( + SubCommand::with_name("check") + .about("Check if a specific tablet is connected. Prints message and returns status code") + .setting(AppSettings::ArgRequiredElseHelp) + .arg( + Arg::with_name("tablet") + .help("Tablet config file name") + .takes_value(true) + ) + ) + .subcommand( + SubCommand::with_name("list") + .about("List all configured devices and their profiles") + ) + .subcommand( + SubCommand::with_name("profile") + .about("Set a specific tablet to use a specific profile") + .setting(AppSettings::ArgRequiredElseHelp) + .arg( + Arg::with_name("tablet") + .help("Tablet config file name") + .takes_value(true) + ) + .arg( + Arg::with_name("profile") + .help("Profile name") + .takes_value(true) + ) + ) + .get_matches(); + + // Handle each subcommand + match matches.subcommand() { + ("check", Some(sub_matches)) => { + let tablet_name = sub_matches.value_of("tablet").unwrap(); + let status = check_tablet(tablet_name); + std::process::exit(status); + } + ("list", Some(_sub_matches)) => { + list_tablets(); + } + ("profile", Some(sub_matches)) => { + let tablet_name = sub_matches.value_of("tablet").unwrap(); + let profile_name = sub_matches.value_of("profile").unwrap(); + set_profile(tablet_name, profile_name); + } + _ => { + println!("{}", matches.usage()); + std::process::exit(1); + } + } +}