diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..35049cbc --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +xtask = "run --package xtask --" diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml index b0453a8e..9f7e0038 100644 --- a/.github/mkdocs.yml +++ b/.github/mkdocs.yml @@ -6,7 +6,7 @@ nav: - Introduction: 'index.md' - User Guide: 'userguide.md' - Contributing: - - Contributing Guide: 'contribute.md' + - Contributing Guide: 'contributing.md' - Roadmap: 'roadmap.md' - Documentation: - Known Issues: 'KnownIssues.md' @@ -86,4 +86,4 @@ plugins: minify_html: true htmlmin_opts: remove_comments: true - cache_safe: true \ No newline at end of file + cache_safe: true diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 0bd2d476..b76b092d 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -20,6 +20,17 @@ jobs: with: fetch-depth: '0' # Fetch all commit history for all branches as well as tags. + - name: Copy Contributing Guidelines + run: | + echo "\n\n$(cat .github/CONTRIBUTING.md)" > 'docs/contributing.md' + + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Commit Contributing Guidelines + file_pattern: "docs/contributing.md" + add_options: '--force' + if: success() + - name: Setup Python uses: actions/setup-python@v5 with: diff --git a/.github/workflows/xtask.yml b/.github/workflows/xtask.yml new file mode 100644 index 00000000..8c1d4b4e --- /dev/null +++ b/.github/workflows/xtask.yml @@ -0,0 +1,56 @@ +name: XTasks + +on: + pull_request: + paths: + - "xtask" + - "Cargo.toml" + - "Cargo.lock" + - ".cargo" + - "core/tabs" + push: + paths: + - "xtask" + - "Cargo.toml" + - "Cargo.lock" + - ".cargo" + - "core/tabs" + +env: + CARGO_TERM_COLOR: always + +jobs: + docgen: + name: DocGen + runs-on: ubuntu-latest + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache Cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-registry- + + - name: Cache Cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo-index- + + - name: Run cargo xtask docgen + run: cargo xtask docgen + + - name: Check uncommitted documentation changes + run: | + git diff + git diff-files --quiet \ + || (echo "Run 'cargo xtask docgen' and push the changes" \ + && exit 1) diff --git a/Cargo.lock b/Cargo.lock index 35864b5c..266ed837 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1418,6 +1418,13 @@ version = "0.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" +[[package]] +name = "xtask" +version = "24.9.28" +dependencies = [ + "linutil_core", +] + [[package]] name = "zerocopy" version = "0.7.35" diff --git a/Cargo.toml b/Cargo.toml index cf43a012..ef31b2a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,14 @@ [workspace.package] license = "MIT" version = "24.9.28" +edition = "2021" [workspace.dependencies] ego-tree = "0.6.2" [workspace] -members = ["tui", "core"] +members = ["tui", "core", "xtask"] +default-members = ["tui", "core"] resolver = "2" [patch.crates-io] diff --git a/docs/contribute.md b/docs/contributing.md similarity index 82% rename from docs/contribute.md rename to docs/contributing.md index e47f8172..4e20b7b7 100644 --- a/docs/contribute.md +++ b/docs/contributing.md @@ -1,4 +1,4 @@ -# How to Contribute? +\n\n# Contributing Guidelines for Linutil Thank you for considering contributing to Linutil! We appreciate your effort in helping improve this project. To ensure that your contributions align with the goals and quality standards of Linutil, please follow these guidelines: @@ -40,22 +40,28 @@ cd linutil - **Make small, targeted PRs**: Focus on one feature or fix per pull request. This makes it easier to review and increases the likelihood of acceptance. - **Avoid combining unrelated changes**: PRs that tackle multiple unrelated issues are harder to review and might be rejected because of a single problem. -## 8. Code Review and Feedback +## 8. Understand and Test the Code You Write + +- **Review your code**: Before submitting your changes, take the time to review your code for readability, efficiency and performance. Consider how your changes affect the project. +- **Avoid using LLMs**: Don't submit AI-generated code without reviewing and testing it first. Ensure that any code you submit is thoroughly understood and meets the project's standards. +- **Testing Requirements**: Failure to conduct testing after multiple requests may result in the closure of your Pull Request. + +## 9. Code Review and Feedback - **Expect feedback**: PRs will undergo code review. Be open to feedback and willing to make adjustments as needed. - **Participate in reviews**: If you feel comfortable, review other contributors' PRs as well. Peer review is a great way to learn and ensure high-quality contributions. -## 9. Contributing Is More Than Just Code +## 10. Contributing Is More Than Just Code - **Test the tool**: Running tests and providing feedback on how the tool works in different environments is a valuable contribution. - **Write well-formed issues**: Clearly describe bugs or problems you encounter, providing as much detail as possible, including steps to reproduce the issue. - **Propose reasonable feature requests**: When suggesting new features, ensure they fit within the scope, style, and design of the project. Provide clear reasoning and use cases. -## 10. Documentation +## 11. Documentation - **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this. -## 11. License +## 12. License - **Agree to the license**: By contributing to Linutil, you agree that your contributions will be licensed under the project's MIT license. diff --git a/docs/userguide.md b/docs/userguide.md index ede99331..a4ee3c84 100644 --- a/docs/userguide.md +++ b/docs/userguide.md @@ -1,81 +1,149 @@ + # Walkthrough ---- - -## System Setup - -- **System Update**: Starts a system-wide update. -- **Compile Setup**: Installs tools and dependencies for compiling software. -- **Gaming Setup**: Configures Steam, Lutris, etc. -- **Global Theming**: Sets up and manages global themes. -- **Remove Snaps**: Removes snap packages. -- **TTY Fonts**: This Script will set the default TTY font to Terminus size 32 Bold - -### Arch Setup - -- **Paru Setup**: Installs the Paru AUR helper. -- **Yay Setup**: Installs the Yay AUR helper. -- **Server Setup**: Installs Arch Linux. - -### Fedora Setup - -- **RPM Fusion Setup**: Adds RPM Fusion free and nonfree repositories. -- **Multimedia Codecs**: Installs multimedia codecs and updates multimedia-related packages. Requires RPM Fusion repositories to be set up first. -- **NVIDIA Proprietary Driver Setup**: Installs proprietary NVIDIA drivers for GPUs from 2014 or later. -- **Virtualization Setup**: Installs virtualization tools. -- **Configure DNF**: Optimizes DNF for better speeds. ## Applications Setup -- **Flathub**: Installs Flatpak and Flathub. -- **Alacritty Setup**: Installs and configures Alacritty for you. -- **DwmTitus Setup**: Sets up the Dwm window manager. -- **Kitty Setup**: Installs and configures Kitty for you. -- **Rofi Setup**: Installs the Rofi application/script launcher. -- **Zsh Setup**: Installs and configures Zsh for you. -- **Fastfetch Setup**: Installs and configures Fastfetch. -- **Linutil Updater**: Updates the Linutil AUR / Crates.io Package. -- **Linutil Installer**: Installs Linutil via Crates.io or AUR. -- **Office Suite Setup**: Installs various office suites and PDF viewers (OnlyOffice, LibreOffice, WPS Office, FreeOffice, Evince, Okular, PDF Studio Viewer, PDF Studio). ### Developer Tools -- **Meld Setup**: Installs Meld, a visual diff and merge tool. -- **Ngrok Setup**: Installs Ngrok, a tool for creating secure tunnels to localhost. -- **Neovim Setup**: Installs and configures Neovim, a Vim-based text editor. -- **VS Code Setup**: Installs Visual Studio Code, a popular text editor. -- **Sublime Setup**: Installs Sublime Text, a nice text editor for code and markup. -- **VS Codium Setup**: Installs VS Codium, an open-source build of VS Code. -- **GitHub Desktop Setup**: Installs GitHub Desktop, a GUI for Git and GitHub. +- **Github Desktop**: 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. +- **Neovim**: Neovim is a refactor, and sometimes redactor, in the tradition of Vim. +It is not a rewrite but a continuation and extension of Vim. +This command configures neovim from CTT's neovim configuration. +https://github.com/ChrisTitusTech/neovim +- **Sublime Text**: 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. +- **VS Code**: 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. +- **VS Codium**: VSCodium is a free, open-source version of Visual Studio Code (VS Code) that removes Microsoft-specific telemetry and branding. +- **Meld**: Meld is a visual diff and merge tool that helps compare files, directories, and version-controlled projects. +- **Ngrok**: Ngrok is a tool that creates secure, temporary tunnels to expose local servers to the internet for testing and development. -## Security Features +### Communication Apps -- **Firewall Baselines**: Sets up firewall rules. +- **Discord**: Discord is a versatile communication platform for gamers and communities, offering voice, video, and text chat features. +- **Jitsi**: Jitsi Meet is an open-source video conferencing tool that allows users to host and join secure meetings directly from their web browsers without the need for downloads. +- **Signal**: Signal is a privacy-focused messaging app that provides end-to-end encryption for secure text, voice, and video communication. +- **Slack**: Slack is a collaboration platform designed for team communication, featuring channels, direct messaging, file sharing, and integrations with various productivity tools. +- **Telegram**: Telegram is a cloud-based messaging app known for its speed and security, offering features like group chats, channels, and end-to-end encrypted calls. +- **Zoom**: Zoom is a widely-used video conferencing platform that allows users to host virtual meetings, webinars, and online collaboration with features like screen sharing and recording. +- **Thunderbird**: Thunderbird is a free, open-source email client that offers powerful features like customizable email management, a built-in calendar, and extensive add-ons for enhanced functionality. + +### Office Suites + + +### PDF Suites + + +### Web Browsers + +- **Brave**: Brave is a free and open-source web browser developed by Brave Software, Inc. based on the Chromium web browser. +- **Chromium**: Chromium is an open-source web browser project started by Google, to provide the source code for the proprietary Google Chrome browser. +- **Google Chrome**: Google Chrome is a fast, secure, and free web browser, built for the modern web. +- **LibreWolf**: LibreWolf is a fork of Firefox, focused on privacy, security, and freedom. +- **Lynx**: Lynx is a highly configurable text-based web browser for use on cursor-addressable character cell terminals. +- **Mozilla Firefox**: Mozilla Firefox is a free and open-source web browser developed by the Mozilla Foundation. +- **Thorium**: Thorium is a Chromium-based browser focused on privacy and performance. +- **Vivaldi**: Vivaldi is a freeware, cross-platform web browser developed by Vivaldi Technologies. +- **Alacritty**: 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. +This command installs and condifures alacritty terminal emulator. +- **Android Debloater**: Universal Android Debloater (UAD) is a tool designed to help users remove bloatware and unnecessary pre-installed applications from Android devices, enhancing performance and user experience. +- **Bash Prompt**: The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems. +It is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful. +This command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository. +https://github.com/ChrisTitusTech/mybash +- **Bottles**: Bottles allows Windows software, like applications and games, to run on Linux. +Bottles also provides tools to categorize, organize and optimize your applications. +- **DWM-Titus**: DWM is a dynamic window manager for X. +It manages windows in tiled, monocle and floating layouts. +All of the layouts can be applied dynamically, optimising the environment for the application in use and the task performed. +This command installs and configures DWM and a desktop manager. +The list of patches applied can be found in CTT's DWM repository +https://github.com/ChrisTitusTech/dwm-titus +- **Docker**: Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers. +- **Fastfetch**: Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily. +It is written mainly in C, with performance and customizability in mind. +This command installs fastfetch and configures from CTT's mybash repository. +https://github.com/ChrisTitusTech/mybash +- **Flatpak / Flathub**: Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns. +This command installs Flatpak and adds the Flathub repository +- **Grub Theme**: Installs ChrisTitusTech's Top 5 Bootloader Themes script to allow for easy customization of GRUB. +- **Kitty**: kitty is a free and open-source GPU-accelerated terminal emulator for Linux, macOS, and some BSD distributions, focused on performance and features. +kitty is written in a mix of C and Python programming languages. + This command installs and configures kitty. +- **Linutil Installer**: Installs a distro-specific Linutil package locally. +- **Linutil Updater**: Updates your local Linutil crate installation. +- **Rofi**: 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. +This command installs and configures rofi with configuration from CTT's DWM repo. +https://github.com/ChrisTitusTech/dwm-titus +- **Waydroid**: Waydroid is an emulator that allows you to run Android apps and games on Linux. +- **ZSH Prompt**: 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. +This command installs ZSH prompt and provides basic configuration. + +## Gaming + + +### Diablo II Resurrected + +- **Loot Filter**: This is a loot filter for Diablo II Resurrected. +It's designed to be a simple, clean, and easy to read loot filter that highlights the most important items. +Works on battle.net and single player. +No frills, no config, just highlights high runes and other valuable items. +For more information visit: https://github.com/ChrisTitusTech/d2r-loot-filter + +## Security + +- **Firewall Baselines (CTT)**: Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall. +This command installs UFW and configures UFW based on CTT's recommended rules. +For more information visit: https://christitus.com/linux-security-mistakes + +## System Setup + + +### Arch Linux + +- **Arch Server Setup**: This command installs a minimal arch server setup under 5 minutes. +- **Paru AUR Helper**: Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction. +To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers +- **Yay AUR Helper**: Yet Another Yogurt - An AUR Helper Written in Go. +To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers + +### Fedora + +- **Configure DNF**: Optimizes DNF for parallel downloads +- **Multimedia Codecs**: This script is designed to install multimedia codecs, and to ensure RPM Fusion repositories are installed. +- **Nvidia Proprietary Drivers**: This script is designed to download the proprietary NVIDIA drivers in Fedora. +- **RPM Fusion**: RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship. +That 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. +For more information visit: https://rpmfusion.org/ +- **Virtualization**: Enables Virtualization through dnf +- **Build Prerequisites**: This script is designed to handle the installation of various software dependencies across different Linux distributions +- **Full System Cleanup**: This script is designed to remove unnecessary packages, clean old cache files, remove temporary files, and to empty the trash. +- **Full System Update**: This command updates your system to the latest packages available for your distro +- **Gaming Dependencies**: This script is designed to handle the installation of gaming dependencies across different Linux distributions +- **Global Theme**: This script is designed to handle the installation and configuration of global theming +- **Remove Snaps**: This script is designed to remove snap +- **TTY Fonts**: This Script will set the default TTY font to Terminus size 32 Bold ## Utilities -- **Wifi Control**: Controls WiFi settings. -- **Numlock Control**: Sets up Numlock on boot. -- **Bluetooth Control**: Controls Bluetooth settings. -### Monitor control +### Monitor Control -- **Reset Scaling**: Resets monitor scaling to native resolution. -- **Scale Monitor**: Scales smaller monitors to the highest resolution of a bigger monitor. -- **Enable Monitor**: Enables a selected monitor. -- **Disable Monitor**: Disables a selected monitor. -- **Set Brightness**: Adjusts brightness for a selected monitor. -- **Set Resolutions**: Sets resolutions for connected monitors. -- **Change Orientation**: Changes the orientation of a selected monitor. -- **Extend Displays**: Extends displays to the right. -- **Duplicate Displays**: Duplicates displays. -- **Manage Arrangement**: Manages the arrangement of multiple monitors. -- **Set Primary Monitor**: Sets a selected monitor as the main display. -- **Auto Detect Displays**: Sets common resolution. +- **Auto Detect Displays**: This utility is designed to detect and apply recommended configuration for monitors connected with your system +- **Change Orientation**: This utility is designed to change the orientation of monitors in your system +- **Disable Monitor**: This utility is designed to disable a monitor in your system +- **Duplicate Displays**: This utility is designed to duplicate display among multi-monitor setup in your system +- **Enable Monitor**: This utility is designed to enable a monitor in your system +- **Extend Displays**: This utility is designed to extend display among multi-monitor setup in your system +- **Manage Arrangement**: This utility is designed to arrange monitors in multi-monitor setup in your system +- **Reset Scaling**: This utility is designed to reset scaling of a monitor in your system +- **Scale Monitors**: This utility is designed to change the scaling of monitors in your system +- **Set Primary Monitor**: This utility is designed to set a Primary monitor in your system ### User Account Manager -- **Add User**: Creates a new user account. -- **Delete User**: Deletes an existing user account. -- **Add to Group**: Adds a user to specified groups. -- **Remove from Group**: Removes a user from specified groups. -- **Change Password**: Changes the password for a user account. +- **Auto Mount Drive**: This utility is designed to help with automating the process of mounting a drive on to your system. +- **Bluetooth Manager**: This utility is designed to manage bluetooth in your system +- **Numlock on Startup**: This utility is designed to configure auto enabling of numlock on boot +- **Ollama**: This utility is designed to manage ollama in your system +- **Service Manager**: This utility is designed to manage services in your system +- **WiFi Manager**: This utility is designed to manage wifi in your system diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml new file mode 100644 index 00000000..277057d9 --- /dev/null +++ b/xtask/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "xtask" +version.workspace = true +license.workspace = true +edition.workspace = true + +[dependencies] +linutil_core = { path = "../core" } diff --git a/xtask/src/docgen.rs b/xtask/src/docgen.rs new file mode 100644 index 00000000..992b83aa --- /dev/null +++ b/xtask/src/docgen.rs @@ -0,0 +1,60 @@ +use std::fs; + +use linutil_core::Command; + +use crate::path; +use crate::DynError; + +pub const USER_GUIDE: &str = "userguide.md"; + +pub fn userguide() -> Result { + let mut md = String::new(); + md.push_str("\n# Walkthrough\n"); + + let tabs = linutil_core::get_tabs(false).1; + + for tab in tabs { + #[cfg(debug_assertions)] + println!("Tab: {}", tab.name); + + md.push_str(&format!("\n## {}\n\n", tab.name)); + + for entry in tab.tree { + if entry.command == Command::None { + #[cfg(debug_assertions)] + println!(" Directory: {}", entry.name); + + if entry.name != "root".to_string() { + md.push_str(&format!("\n### {}\n\n", entry.name)); + } + + /* let current_dir = &entry.name; + + if *current_dir != "root".to_string() { + md.push_str(&format!( + "\n
{}\n\n", + current_dir + )); + } */ // Commenting this for now, might be a good idea later + } else { + if !entry.description.is_empty() { + #[cfg(debug_assertions)] + println!(" Entry: {}", entry.name); + #[cfg(debug_assertions)] + println!(" Description: {}", entry.description); + + md.push_str(&format!("- **{}**: {}\n", entry.name, entry.description)); + } /* else { + md.push_str(&format!("- **{}**\n", entry.name)); + } */ // https://github.com/ChrisTitusTech/linutil/pull/753 + } + } + } + + Ok(md) +} + +pub fn write(file: &str, data: &str) { + let path = path::docs().join(file); + fs::write(path, data).unwrap_or_else(|_| panic!("Could not write to {}", file)); +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs new file mode 100644 index 00000000..fecab8c8 --- /dev/null +++ b/xtask/src/main.rs @@ -0,0 +1,40 @@ +mod docgen; +mod path; + +use std::{env, error::Error}; + +type DynError = Box; + +pub mod tasks { + use crate::docgen::USER_GUIDE; + use crate::docgen::{userguide, write}; + use crate::DynError; + + pub fn docgen() -> Result<(), DynError> { + write(USER_GUIDE, &userguide()?); + Ok(()) + } + + pub fn print_help() { + println!( + " +Usage: `cargo xtask ` + + Tasks: + docgen: Generate Markdown files. +" + ); + } +} + +fn main() -> Result<(), DynError> { + let task = env::args().nth(1); + match task { + None => tasks::print_help(), + Some(t) => match t.as_str() { + "docgen" => tasks::docgen()?, + invalid => return Err(format!("Invalid task: {}", invalid).into()), + }, + }; + Ok(()) +} diff --git a/xtask/src/path.rs b/xtask/src/path.rs new file mode 100644 index 00000000..9a3c6230 --- /dev/null +++ b/xtask/src/path.rs @@ -0,0 +1,12 @@ +use std::path::{Path, PathBuf}; + +pub fn project_root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")) + .parent() + .unwrap() + .to_path_buf() +} + +pub fn docs() -> PathBuf { + project_root().join("docs/") +}