From f6748caab737f57437a75325d780b5b81aa75d20 Mon Sep 17 00:00:00 2001 From: Adam Perkowski Date: Sun, 22 Sep 2024 18:10:05 +0200 Subject: [PATCH] feat: short disclaimer-like script descriptions (#593) * names updated Co-authored-by: nnyyxxxx * idea * Added missing tasks * Added a title --------- Co-authored-by: nnyyxxxx --- core/src/inner.rs | 6 ++++ core/src/lib.rs | 1 + core/tabs/applications-setup/tab_data.toml | 39 ++++++++++++++++------ core/tabs/gaming/tab_data.toml | 3 +- core/tabs/security/tab_data.toml | 1 + core/tabs/system-setup/tab_data.toml | 32 ++++++++++++++---- core/tabs/utils/tab_data.toml | 11 ++++++ tui/src/state.rs | 37 ++++++++++++++++++-- 8 files changed, 110 insertions(+), 20 deletions(-) diff --git a/core/src/inner.rs b/core/src/inner.rs index 00761c2d..bd45cc13 100644 --- a/core/src/inner.rs +++ b/core/src/inner.rs @@ -34,6 +34,7 @@ pub fn get_tabs(validate: bool) -> Vec { name: "root".to_string(), description: String::new(), command: Command::None, + task_list: String::new(), }); let mut root = tree.root_mut(); create_directory(data, &mut root, &directory); @@ -83,6 +84,8 @@ struct Entry { command: Option, #[serde(default)] script: Option, + #[serde(default)] + task_list: String, } impl Entry { @@ -168,6 +171,7 @@ fn create_directory(data: Vec, node: &mut NodeMut, command_dir: name: entry.name, description: entry.description, command: Command::None, + task_list: String::new(), }); create_directory(entries, &mut node, command_dir); } else if let Some(command) = entry.command { @@ -175,6 +179,7 @@ fn create_directory(data: Vec, node: &mut NodeMut, command_dir: name: entry.name, description: entry.description, command: Command::Raw(command), + task_list: String::new(), }); } else if let Some(script) = entry.script { let dir = command_dir.join(script); @@ -185,6 +190,7 @@ fn create_directory(data: Vec, node: &mut NodeMut, command_dir: name: entry.name, description: entry.description, command: Command::LocalFile(dir), + task_list: entry.task_list, }); } else { panic!("Entry must have data"); diff --git a/core/src/lib.rs b/core/src/lib.rs index 1d52116b..3f7d36a3 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -24,4 +24,5 @@ pub struct ListNode { pub name: String, pub description: String, pub command: Command, + pub task_list: String, } diff --git a/core/tabs/applications-setup/tab_data.toml b/core/tabs/applications-setup/tab_data.toml index 350063b1..b8bab3b3 100644 --- a/core/tabs/applications-setup/tab_data.toml +++ b/core/tabs/applications-setup/tab_data.toml @@ -4,44 +4,52 @@ name = "Applications Setup" name = "Developer Tools" [[data.entries]] -name = "Install Github Desktop" +name = "Github Desktop" description = "GitHub Desktop is a user-friendly application that simplifies the process of managing Git repositories and interacting with GitHub, providing a graphical interface for tasks like committing, branching, and syncing changes." script = "Developer-tools/githubdesktop-setup.sh" +task_list = "installation" [[data.entries]] -name = "Setup Neovim" +name = "Neovim" description = "Neovim is a refactor, and sometimes redactor, in the tradition of Vim.\nIt is not a rewrite but a continuation and extension of Vim.\nThis command configures neovim from CTT's neovim configuration.\nhttps://github.com/ChrisTitusTech/neovim" script = "Developer-tools/neovim-setup.sh" +task_list = "installation, file modification" [[data.entries]] -name = "Install Sublime" +name = "Sublime Text" description = "Sublime Text is a fast, lightweight, and customizable text editor known for its simplicity, powerful features, and wide range of plugins for various programming languages." script = "Developer-tools/sublime-setup.sh" +task_list = "installation" [[data.entries]] -name = "Install VS Code" +name = "VS Code" description = "Visual Studio Code (VS Code) is a lightweight, open-source code editor with built-in support for debugging, version control, and extensions for various programming languages and frameworks." script = "Developer-tools/vscode-setup.sh" +task_list = "installation" [[data.entries]] -name = "Install VS Codium" +name = "VS Codium" description = "VSCodium is a free, open-source version of Visual Studio Code (VS Code) that removes Microsoft-specific telemetry and branding." script = "Developer-tools/vscodium-setup.sh" +task_list = "installation" [[data.entries]] -name = "Install Meld" +name = "Meld" description = "Meld is a visual diff and merge tool that helps compare files, directories, and version-controlled projects." script = "Developer-tools/meld-setup.sh" +task_list = "installation to ~/meld" [[data.entries]] -name = "Install Ngrok" +name = "Ngrok" description = "Ngrok is a tool that creates secure, temporary tunnels to expose local servers to the internet for testing and development." script = "Developer-tools/ngrok-setup.sh" +task_list = "installation" [[data]] name = "Alacritty" description = "Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.\nThis command installs and condifures alacritty terminal emulator." script = "alacritty-setup.sh" +task_list = "installation, file modification" [[data]] name = "Android Debloater" @@ -52,40 +60,48 @@ script = "android-debloat.sh" name = "Bash Prompt" description = "The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems.\nIt is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful.\nThis command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash" script = "mybash-setup.sh" +task_list = "installation, file modification" [[data]] -name = "Bottles setup" +name = "Bottles" script = "bottles-setup.sh" +task_list = "flatpak installation" [[data]] -name = "Browser Setup" +name = "Web Browsers" description = "An interactive script to install popular browsers." script = "browser-setup.sh" +task_list = "installation" [[data]] name = "DWM-Titus" description = "DWM is a dynamic window manager for X.\nIt manages windows in tiled, monocle and floating layouts.\nAll of the layouts can be applied dynamically, optimising the environment for the application in use and the task performed.\nThis command installs and configures DWM and a desktop manager.\nThe list of patches applied can be found in CTT's DWM repository\nhttps://github.com/ChrisTitusTech/dwm-titus" script = "dwmtitus-setup.sh" +task_list = "installation, privileged file modification, systemd actions" [[data]] name = "Fastfetch" description = "Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily.\nIt is written mainly in C, with performance and customizability in mind.\nThis command installs fastfetch and configures from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash" script = "fastfetch-setup.sh" +task_list = "installation, file modification" [[data]] name = "Flatpak / Flathub" description = "Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns.\nThis command installs Flatpak and adds the Flathub repository" script = "setup-flatpak.sh" +task_list = "installation" [[data]] name = "Kitty" description = "kitty is a free and open-source GPU-accelerated terminal emulator for Linux, macOS, and some BSD distributions, focused on performance and features.\nkitty is written in a mix of C and Python programming languages.\n This command installs and configures kitty." script = "kitty-setup.sh" +task_list = "installation, file modification" [[data]] name = "Linutil Installer" description = "Installs a distro-specific Linutil package locally." script = "linutil-installer.sh" +task_list = "installation" [[data.preconditions]] matches = false @@ -106,11 +122,13 @@ values = [ "linutil" ] name = "Office Suite" description = "An office suite installer is a software package that installs productivity tools such as word processing, spreadsheets, presentations, and pdf viewers for business and personal use." script = "office-suite-setup.sh" +task_list = "installation" [[data]] name = "Rofi" description = "Rofi is a window switcher, run dialog, ssh-launcher and dmenu replacement that started as a clone of simpleswitcher, written by Sean Pringle and later expanded by Dave Davenport.\nThis command installs and configures rofi with configuration from CTT's DWM repo.\nhttps://github.com/ChrisTitusTech/dwm-titus" script = "rofi-setup.sh" +task_list = "installation, file modification" [[data]] name = "Waydroid" @@ -125,4 +143,5 @@ values = [ "wayland", "Wayland" ] [[data]] name = "ZSH Prompt" description = "The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.\nThis command installs ZSH prompt and provides basic configuration." -script = "zsh-setup.sh" \ No newline at end of file +script = "zsh-setup.sh" +task_list = "installation, file modification" diff --git a/core/tabs/gaming/tab_data.toml b/core/tabs/gaming/tab_data.toml index 6fc7aa37..d3484d51 100644 --- a/core/tabs/gaming/tab_data.toml +++ b/core/tabs/gaming/tab_data.toml @@ -4,6 +4,7 @@ name = "Gaming" name = "Diablo II Resurrected" [[data.entries]] -name = "Loot Filter Install" +name = "Loot Filter" description = "This is a loot filter for Diablo II Resurrected.\nIt's designed to be a simple, clean, and easy to read loot filter that highlights the most important items.\nWorks on battle.net and single player.\nNo frills, no config, just highlights high runes and other valuable items.\nFor more information visit: https://github.com/ChrisTitusTech/d2r-loot-filter" script = "diablo-ii/d2r-loot-filters.sh" +task_list = "file modification" diff --git a/core/tabs/security/tab_data.toml b/core/tabs/security/tab_data.toml index c899d4d9..303fbae8 100644 --- a/core/tabs/security/tab_data.toml +++ b/core/tabs/security/tab_data.toml @@ -4,3 +4,4 @@ name = "Security" name = "Firewall Baselines (CTT)" description = "Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall.\nThis command installs UFW and configures UFW based on CTT's recommended rules.\nFor more information visit: https://christitus.com/linux-security-mistakes" script = "firewall-baselines.sh" +task_list = "installation" diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml index 22612d94..e36bbca0 100644 --- a/core/tabs/system-setup/tab_data.toml +++ b/core/tabs/system-setup/tab_data.toml @@ -13,16 +13,19 @@ values = ["pacman"] name = "Arch Server Setup" description = "This command installs a minimal arch server setup under 5 minutes." script = "arch/server-setup.sh" +task_list = "full system installation, including partitioning" [[data.entries]] name = "Paru AUR Helper" description = "Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction.\nTo know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers" script = "arch/paru-setup.sh" +task_list = "installation" [[data.entries]] name = "Yay AUR Helper" description = "Yet Another Yogurt - An AUR Helper Written in Go.\nTo know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers" script = "arch/yay-setup.sh" +task_list = "installation" [[data]] name = "Fedora" @@ -36,66 +39,81 @@ values = ["dnf"] name = "Configure DNF" description = "Optimizes DNF for parallel downloads" script = "fedora/configure-dnf.sh" +task_list = "privileged file modification" [[data.entries]] -name = "Multimedia Setup" +name = "Multimedia Codecs" script = "fedora/multimedia-codecs.sh" +task_list = "installation" [[data.entries]] -name = "Nvidia Proprietary Driver Setup" +name = "Nvidia Proprietary Drivers" script = "fedora/nvidia-proprietary-driver-setup.sh" +task_list = "installation" [[data.entries]] -name = "RPM Fusion Setup" +name = "RPM Fusion" description = "RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship.\nThat software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit.\nFor more information visit: https://rpmfusion.org/" script = "fedora/rpm-fusion-setup.sh" +task_list = "repo installation" [[data.entries]] -name = "Virtualization Setup" +name = "Virtualization" description = "Enables Virtualization through dnf" script = "fedora/virtualization.sh" +task_list = "installation" [[data]] name = "Auto Mount Drive" script = "auto-mount.sh" +task_list = "privileged file modification" [[data]] name = "Build Prerequisites" description = "This script is designed to handle the installation of various software dependencies across different Linux distributions" script = "compile-setup.sh" +task_list = "installation" [[data]] -name = "Docker Setup" +name = "Docker" script = "docker-setup.sh" +task_list = "installation, systemd actions" [[data]] name = "Full System Cleanup" script = "system-cleanup.sh" +task_list = "package removal, privileged file modification" [[data]] name = "Full System Update" description = "This command updates your system to the latest packages available for your distro" script = "system-update.sh" +task_list = "privileged file modification" [[data]] name = "Gaming Dependencies" description = "This script is designed to handle the installation of gaming dependencies across different Linux distributions" script = "gaming-setup.sh" +task_list = "installation" [[data]] name = "Global Theme" description = "This script is designed to handle the installation and configuration of global theming" script = "global-theme.sh" +task_list = "installation, privileged file modification" [[data]] -name = "Grub Theme Setup" +name = "Grub Theme" script = "grub-theme.sh" +task_list = "privileged file modification" [[data]] name = "Remove Snaps" description = "This script is designed to remove snap" script = "remove-snaps.sh" +task_list = "package removal" [[data]] -name = "SSH-Samba Setup" +name = "SSH-Samba" script = "samba-ssh-setup.sh" +task_list = "installation, systemd actions, privileged file modification" diff --git a/core/tabs/utils/tab_data.toml b/core/tabs/utils/tab_data.toml index 050d72f1..d825840c 100644 --- a/core/tabs/utils/tab_data.toml +++ b/core/tabs/utils/tab_data.toml @@ -96,48 +96,59 @@ script = "user-account-manager/remove_from_group.sh" [[data]] name = "Auto Login" script = "auto-login.sh" +task_list = "DE setup" [[data]] name = "Auto Power Profiling" script = "power-profile.sh" +task_list = "installation" [[data]] name = "Bluetooth Manager" description = "This utility is designed to manage bluetooth in your system" script = "bluetooth-control.sh" +task_list = "installation, systemd actions" [[data]] name = "Bootable USB Creator" script = "create-bootable-usb.sh" +task_list = "disk modification" [[data]] name = "Crypto tool" script = "encrypt_decrypt_tool.sh" +task_list = "installation, file modification" [[data]] name = "Numlock on Startup" description = "This utility is designed to configure auto enabling of numlock on boot" script = "numlock.sh" +task_list = "privileged file modification, systemd actions" [[data]] name = "Ollama" description = "This utility is designed to manage ollama in your system" script = "ollama.sh" +task_list = "installation, systemd actions" [[data]] name = "Service Manager" description = "This utility is designed to manage services in your system" script = "service-control.sh" +task_list = "installation, privileged file modification, systemd actions" [[data]] name = "SSH Commands" script = "ssh.sh" +task_list = "installation, file modification, systemd actions" [[data]] name = "Timeshift Backup" script = "timeshift.sh" +task_list = "installation" [[data]] name = "WiFi Manager" description = "This utility is designed to manage wifi in your system" script = "wifi-control.sh" +task_list = "installation, systemd actions" diff --git a/tui/src/state.rs b/tui/src/state.rs index 26f041e5..a9049528 100644 --- a/tui/src/state.rs +++ b/tui/src/state.rs @@ -198,13 +198,21 @@ impl AppState { .constraints([Constraint::Length(3), Constraint::Min(1)].as_ref()) .split(horizontal[1]); + let list_chunks = Layout::default() + .direction(Direction::Horizontal) + .constraints([Constraint::Percentage(60), Constraint::Percentage(40)].as_ref()) + .split(chunks[1]); + self.filter.draw_searchbar(frame, chunks[0], &self.theme); let mut items: Vec = Vec::new(); + let mut task_items: Vec = Vec::new(); + if !self.at_root() { items.push( Line::from(format!("{} ..", self.theme.dir_icon())).style(self.theme.dir_color()), ); + task_items.push(Line::from(" ").style(self.theme.dir_color())); } items.extend(self.filter.item_list().iter().map( @@ -238,6 +246,21 @@ impl AppState { }, )); + task_items.extend(self.filter.item_list().iter().map( + |ListEntry { + node, has_children, .. + }| { + if *has_children { + Line::from(" ").style(self.theme.dir_color()) + } else { + Line::from(format!("{} ", node.task_list)) + .alignment(Alignment::Right) + .style(self.theme.cmd_color()) + .bold() + } + }, + )); + let style = if let Focus::List = self.focus { Style::default().reversed() } else { @@ -255,17 +278,27 @@ impl AppState { #[cfg(not(feature = "tips"))] let bottom_title = ""; + let task_list_title = Line::from("Important Actions ").right_aligned(); + // Create the list widget with items let list = List::new(items) .highlight_style(style) .block( Block::default() - .borders(Borders::ALL) + .borders(Borders::ALL & !Borders::RIGHT) .title(title) .title_bottom(bottom_title), ) .scroll_padding(1); - frame.render_stateful_widget(list, chunks[1], &mut self.selection); + frame.render_stateful_widget(list, list_chunks[0], &mut self.selection); + + let disclaimer_list = List::new(task_items).highlight_style(style).block( + Block::default() + .borders(Borders::ALL & !Borders::LEFT) + .title(task_list_title), + ); + + frame.render_stateful_widget(disclaimer_list, list_chunks[1], &mut self.selection); if let Focus::FloatingWindow(float) = &mut self.focus { float.draw(frame, chunks[1]);