Merge branch 'main' into multi-select-refact

This commit is contained in:
JEEVITHA KANNAN K S 2024-11-01 00:45:24 +05:30 committed by GitHub
commit 8826e538b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
73 changed files with 1315 additions and 585 deletions

2
.cargo/config.toml Normal file
View File

@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"

View File

@ -16,6 +16,7 @@ cd linutil
```
## 3. Make your changes
- **Edit the files you want to change**: Make your changes to the relevant files.
- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
@ -60,6 +61,7 @@ cd linutil
## 11. Documentation
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
- **Automatic generation**: If you decide to add functionality through a new shell script, make sure to fill out all fields in `tab_data.toml` and run `cargo xtask docgen`.
## 12. License

19
.github/SECURITY.md vendored
View File

@ -2,13 +2,20 @@
## Supported Versions
It is recommended that you run the stable version as this is more tested and used by most. The dev branch is bleed-edge commits that are not well tested and aren't meant to be used in production environments
It is recommended that you use the stable branch as it's tested and used by most. The dev branch may contain bleeding-edge commits that are not well tested and are not meant to be used in production environments.<br>
Version tags lower than the [latest stable release](https://github.com/ChrisTitusTech/linutil/releases/latest) are **not** supported.
| Version | Supported |
| ------- | ------------------ |
| latest | :white_check_mark: |
| dev | :x: |
| Branch | Supported |
| ------- | ---------------------- |
| Stable | :white_check_mark: YES |
| Dev | :x: NO |
| Version | Supported |
| -------------------------------------------------- | ---------------------- |
| [![LATEST](https://img.shields.io/github/v/release/ChrisTitusTech/linutil?color=%230567ff&label=Latest&style=for-the-badge)](https://github.com/ChrisTitusTech/linutil/releases/latest) | :white_check_mark: YES |
| Below LATEST | :x: NO |
| Above LATEST | :x: NO |
## Reporting a Vulnerability
I'd recommend making an Issue for reporting a bug. If you would like privately submit the bug you can email me at contact@christitus.com
If you have any reason to believe there are security vulnerabilities in Linutil, fill out the [report form](https://github.com/christitustech/linutil/security/advisories/new) or e-mail [contact@christitus.com](mailto:contact@christitus.com).

4
.github/mkdocs.yml vendored
View File

@ -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
cache_safe: true

29
.github/release.yml vendored
View File

@ -2,19 +2,34 @@ changelog:
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '⚙️ Refactoring'
labels:
- 'refactor'
- title: '🧩 UI/UX'
labels:
- 'UI/UX'
- title: '📚 Documentation'
label: 'documentation'
labels:
- 'documentation'
- title: '🔒 Security'
label: 'security'
labels:
- 'security'
- title: '🧰 GitHub Actions'
label: 'github actions'
labels:
- 'github_actions'
- title: '🦀 Rust'
labels:
- 'rust'
- title: '📃 Scripting'
labels:
- 'script'
- title: 'Other Changes'
labels:
- "*"
exclude:
labels:
- 'skip-changelog'
- 'skip-changelog'

View File

@ -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 -e "<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->\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:

View File

@ -89,22 +89,23 @@ jobs:
version: ${{ env.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install vhs
- name: Setup Preview
run: |
wget 'https://github.com/charmbracelet/vhs/releases/download/v0.8.0/vhs_0.8.0_amd64.deb'
sudo apt install -y ffmpeg
sudo snap install ttyd --classic
sudo dpkg -i 'vhs_0.8.0_amd64.deb'
echo "$(pwd)/build" >> $GITHUB_PATH
- name: Generate preview
uses: charmbracelet/vhs-action@v2.1.0
with:
path: "docs/assets/preview.tape"
- name: Build the preview
- name: Move preview
run: |
export PATH="$(pwd)/build:$PATH"
vhs docs/assets/preview.tape -o docs/assets/preview.gif
mv preview.gif docs/assets/preview.gif
- name: Upload the preview
- name: Upload preview
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Preview for ${{ env.version }}
file_pattern: "docs/assets/preview.gif"
add_options: "--force"
if: success()
if: success()

View File

@ -5,7 +5,7 @@ on:
branches: ["main"]
paths:
- '**/*.rs'
- 'Cargo.toml'
- '**/Cargo.toml'
- 'Cargo.lock'
env:

View File

@ -1,9 +1,9 @@
name: ShellCheck
name: Script Checks
on:
pull_request:
paths:
- 'core/tabs/**/*.sh'
- '**/*.sh'
workflow_dispatch:
jobs:
@ -11,20 +11,24 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git fetch origin ${{ github.base_ref }}
- name: Checkout sources
uses: actions/checkout@v4
- name: Download and set up shellcheck
run : |
wget https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz
tar -xf shellcheck-v0.10.0.linux.x86_64.tar.xz
cd shellcheck-v0.10.0
chmod +x shellcheck
- name: Run ShellCheck
uses: reviewdog/action-shellcheck@v1
with:
reviewdog_flags: '-fail-level=any'
- name: Run shellcheck
run: |
for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then
./shellcheck-v0.10.0/shellcheck -S error "$file"
fi
done
shfmt:
name: Shell Fomatting
runs-on: ubuntu-latest
needs: shellcheck
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Run shfmt
uses: reviewdog/action-shfmt@v1
with:
shfmt_flags: '-i 4 -ci'
reviewdog_flags: '-fail-level=any'

15
.github/workflows/typos.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Check for typos
on:
[push, pull_request, workflow_dispatch]
jobs:
check-typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: git fetch origin ${{ github.base_ref }}
- name: Run spellcheck
uses: crate-ci/typos@v1.25.0

58
.github/workflows/xtask.yml vendored Normal file
View File

@ -0,0 +1,58 @@
name: XTasks
on:
pull_request:
paths:
- "xtask"
- "Cargo.toml"
- "Cargo.lock"
- ".cargo"
- "core/tabs"
- "docs"
push:
paths:
- "xtask"
- "Cargo.toml"
- "Cargo.lock"
- ".cargo"
- "core/tabs"
- "docs"
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)

43
Cargo.lock generated
View File

@ -165,9 +165,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.18"
version = "1.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476"
checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1"
dependencies = [
"shlex",
]
@ -194,9 +194,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.5.18"
version = "4.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3"
checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615"
dependencies = [
"clap_builder",
"clap_derive",
@ -204,9 +204,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.5.18"
version = "4.5.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b"
checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b"
dependencies = [
"anstream",
"anstyle",
@ -972,6 +972,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "streaming-iterator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520"
[[package]]
name = "strsim"
version = "0.11.1"
@ -1028,18 +1034,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.63"
version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.63"
version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
dependencies = [
"proc-macro2",
"quote",
@ -1082,13 +1088,14 @@ dependencies = [
[[package]]
name = "tree-sitter"
version = "0.23.0"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20f4cd3642c47a85052a887d86704f4eac272969f61b686bdd3f772122aabaff"
checksum = "23b84f60031bf8245b563a80c92c1034e557a914f7958f474bc0afa2eed78b98"
dependencies = [
"cc",
"regex",
"regex-syntax",
"streaming-iterator",
"tree-sitter-language",
]
@ -1104,12 +1111,13 @@ dependencies = [
[[package]]
name = "tree-sitter-highlight"
version = "0.23.0"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395d7a477a4504fd7d5e4d003e0dd41bd5b9c4985d53592a943a8354ec452dae"
checksum = "5c727fb31f816c09fc54dc0e971d101318926866f7261b2acb820e84a61bf52d"
dependencies = [
"lazy_static",
"regex",
"streaming-iterator",
"thiserror",
"tree-sitter",
]
@ -1410,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"

View File

@ -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]

View File

@ -49,7 +49,7 @@ makepkg -si
Replace `<package>` with your preferred package.
If you use [yay](https://github.com/Jguer/yay), [paru](https://github.com/Morganamilo/paru) or any other [AUR Helper](https://wiki.archlinux.org/title/AUR_helpers), it's even simplier:
If you use [yay](https://github.com/Jguer/yay), [paru](https://github.com/Morganamilo/paru) or any other [AUR Helper](https://wiki.archlinux.org/title/AUR_helpers), it's even simpler:
```bash
paru -S linutil

7
_typos.toml Normal file
View File

@ -0,0 +1,7 @@
[files]
extend-exclude = ["tui/cool_tips.txt"]
[default]
extend-ignore-identifiers-re = [
"ratatui",
]

View File

@ -3,37 +3,37 @@
. ../../common-script.sh
installSublime() {
if ! command_exists sublime; then
printf "%b\n" "${YELLOW}Installing Sublime...${RC}"
case "$PACKAGER" in
apt-get|nala)
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
;;
zypper)
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
"$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo
"$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text
;;
pacman)
"$AUR_HELPER" -S --needed --noconfirm sublime-text-4
;;
dnf)
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Sublime is already installed.${RC}"
fi
if ! command_exists sublime; then
printf "%b\n" "${YELLOW}Installing Sublime...${RC}"
case "$PACKAGER" in
apt-get|nala)
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
;;
zypper)
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
"$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo
"$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text
;;
pacman)
"$AUR_HELPER" -S --needed --noconfirm sublime-text-4
;;
dnf)
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Sublime is already installed.${RC}"
fi
}

View File

@ -0,0 +1,25 @@
#!/bin/sh -e
. ../../common-script.sh
installWaterfox() {
if ! command_exists waterfox; then
printf "%b\n" "${YELLOW}Installing waterfox...${RC}"
case "$PACKAGER" in
pacman)
"$AUR_HELPER" -S --needed --noconfirm waterfox-bin
;;
*)
. ../setup-flatpak.sh
flatpak install -y flathub net.waterfox.waterfox
;;
esac
else
printf "%b\n" "${GREEN}Waterfox is already installed.${RC}"
fi
}
checkEnv
checkEscalationTool
checkAURHelper
installWaterfox

View File

@ -26,6 +26,12 @@ install_docker() {
apt-get|nala)
curl -fsSL https://get.docker.com | sh
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
"$ESCALATION_TOOL" "$PACKAGER" -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin
"$ESCALATION_TOOL" systemctl enable --now docker
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker
"$ESCALATION_TOOL" systemctl enable docker
@ -49,6 +55,11 @@ install_docker_compose() {
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
"$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose
;;

View File

@ -4,8 +4,12 @@
themeinstall(){
mkdir -p "$HOME/.local/share"
cd "$HOME/.local/share" && git clone "https://github.com/ChrisTitusTech/Top-5-Bootloader-Themes"
cd "$HOME/.local/share/Top-5-Bootloader-Themes"
cd "$HOME/.local/share"
if [ -d 'Top-5-Bootloader-Themes' ]; then
rm -rf 'Top-5-Bootloader-Themes'
fi
git clone "https://github.com/ChrisTitusTech/Top-5-Bootloader-Themes"
cd "Top-5-Bootloader-Themes"
"$ESCALATION_TOOL" ./install.sh
}

View File

@ -35,10 +35,10 @@ installLinutil() {
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm curl rustup man-db
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
"$ESCALATION_TOOL" "$PACKAGER" install -y curl rustup man-pages man-db man
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
@ -54,12 +54,23 @@ installLinutil() {
rustup default stable
cargo install --force linutil_tui
printf "%b\n" "${GREEN}Installed successfully.${RC}"
installExtra
;;
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
esac
esac
}
installExtra() {
printf "%b\n" "${YELLOW}Installing the manpage...${RC}"
"$ESCALATION_TOOL" mkdir -p /usr/share/man/man1
curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/man/linutil.1' | "$ESCALATION_TOOL" tee '/usr/share/man/man1/linutil.1' > /dev/null
printf "%b\n" "${YELLOW}Creating a Desktop Entry...${RC}"
"$ESCALATION_TOOL" mkdir -p /usr/share/applications
curl 'https://raw.githubusercontent.com/ChrisTitusTech/linutil/refs/heads/main/linutil.desktop' | "$ESCALATION_TOOL" tee /usr/share/applications/linutil.desktop > /dev/null
printf "%b\n" "${GREEN}Done.${RC}"
}
checkEnv
checkEscalationTool
checkAURHelper

View File

@ -5,16 +5,16 @@
gitpath="$HOME/.local/share/mybash"
installDepend() {
if ! command_exists bash bash-completion tar bat tree unzip fontconfig git; then
printf "%b\n" "${YELLOW}Installing Bash...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig git
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig git
;;
esac
if [ ! -f "/usr/share/bash-completion/bash_completion" ] || ! command_exists bash tar bat tree unzip fc-list git; then
printf "%b\n" "${YELLOW}Installing Bash...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig git
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig git
;;
esac
fi
}

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installFreeOffice() {
if ! command_exists softmaker-freeoffice-2024 freeoffice softmaker; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installLibreOffice() {
if ! command_exists libreoffice; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installOnlyOffice() {
if ! command_exists onlyoffice-desktopeditors; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installWpsOffice() {
if ! command_exists com.wps.Office; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installEvince() {
if ! command_exists evince; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installOkular() {
if ! command_exists okular; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installPdfstudio() {
if ! command_exists pdfstudio2024; then

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ../common-script.sh
. ../../common-script.sh
installPdfstudioviewer() {
if ! command_exists pdfstudioviewer2024; then

View File

@ -1,50 +1,5 @@
name = "Applications Setup"
[[data]]
name = "Developer Tools"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I FM"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I FI"
[[data.entries]]
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 = "I"
[[data]]
name = "Communication Apps"
@ -78,21 +33,71 @@ description = "Telegram is a cloud-based messaging app known for its speed and s
script = "communication-apps/telegram-setup.sh"
task_list = "I"
[[data.entries]]
name = "Zoom"
description = "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."
script = "communication-apps/zoom-setup.sh"
task_list = "I"
[[data.entries]]
name = "Thunderbird"
description = "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."
script = "communication-apps/thunderbird-setup.sh"
task_list = "I"
[[data.entries]]
name = "Zoom"
description = "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."
script = "communication-apps/zoom-setup.sh"
task_list = "I"
[[data]]
name = "Developer Tools"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I FI"
[[data.entries]]
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 = "I FM"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I"
[[data.entries]]
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 = "I"
[[data]]
name = "Office Suites"
[[data.entries]]
name = "FreeOffice"
script = "office-suites/freeoffice.sh"
task_list = "I"
[[data.entries]]
name = "LibreOffice"
script = "office-suites/libreoffice.sh"
@ -103,11 +108,6 @@ name = "OnlyOffice"
script = "office-suites/onlyoffice.sh"
task_list = "I"
[[data.entries]]
name = "FreeOffice"
script = "office-suites/freeoffice.sh"
task_list = "I"
[[data.entries]]
name = "WPS Office"
script = "office-suites/wpsoffice.sh"
@ -186,6 +186,12 @@ description = "Vivaldi is a freeware, cross-platform web browser developed by Vi
script = "browsers/vivaldi.sh"
task_list = "I"
[[data.entries]]
name = "waterfox"
description = "Waterfox is the privacy-focused web browser engineered to give you speed, control, and peace of mind on the internet."
script = "browsers/waterfox.sh"
task_list = "FI"
[[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."
@ -210,18 +216,18 @@ description = "Bottles allows Windows software, like applications and games, to
script = "bottles-setup.sh"
task_list = "FI"
[[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 = "I PFM SS"
[[data]]
name = "Docker"
description = "Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers."
script = "docker-setup.sh"
task_list = "I SS"
[[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 = "I PFM SS"
[[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"
@ -288,4 +294,4 @@ values = [ "wayland", "Wayland" ]
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"
task_list = "I FM"
task_list = "I FM"

View File

@ -15,10 +15,17 @@ installWaydroid() {
case "$PACKAGER" in
pacman)
"$AUR_HELPER" -S --needed --noconfirm waydroid
if command_exists dkms; then
"$AUR_HELPER" -S --needed --noconfirm binder_linux-dkms
"$ESCALATION_TOOL" modprobe binder-linux device=binder,hwbinder,vndbinder
if ! command_exists dkms; then
installed_kernels=$("$PACKAGER" -Q | grep -E '^linux(| |-rt|-rt-lts|-hardened|-zen|-lts)[^-headers]' | cut -d ' ' -f 1)
for kernel in $installed_kernels; do
header="${kernel}-headers"
printf "%b\n" "${CYAN}Installing headers for $kernel...${RC}"
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$header"
done
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm dkms
fi
"$AUR_HELPER" -S --needed --noconfirm binder_linux-dkms
"$ESCALATION_TOOL" modprobe binder-linux device=binder,hwbinder,vndbinder
;;
apt-get|nala)
curl https://repo.waydro.id | "$ESCALATION_TOOL" sh

View File

@ -44,6 +44,7 @@ RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f'
EOL
# Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory
[ ! -f /etc/zsh/zshenv ] && "$ESCALATION_TOOL" mkdir -p /etc/zsh && "$ESCALATION_TOOL" touch /etc/zsh/zshenv
echo "export ZDOTDIR=\"$HOME/.config/zsh\"" | "$ESCALATION_TOOL" tee -a /etc/zsh/zshenv
}

View File

@ -9,7 +9,10 @@ CYAN='\033[36m'
GREEN='\033[32m'
command_exists() {
command -v "$1" >/dev/null 2>&1
for cmd in "$@"; do
command -v "$cmd" >/dev/null 2>&1 || return 1
done
return 0
}
checkAURHelper() {

View File

@ -30,7 +30,7 @@ configureUFW() {
printf "%b\n" "${YELLOW}Allowing port 80/tcp (UFW)${RC}"
"$ESCALATION_TOOL" ufw allow 80/tcp
printf "%b\n" "${YELLO}Allowing port 443/tcp (UFW)${RC}"
printf "%b\n" "${YELLOW}Allowing port 443/tcp (UFW)${RC}"
"$ESCALATION_TOOL" ufw allow 443/tcp
printf "%b\n" "${YELLOW}Denying Incoming Packets by Default(UFW)${RC}"

View File

@ -8,8 +8,8 @@ installDepend() {
if ! command_exists paru; then
printf "%b\n" "${YELLOW}Installing paru as AUR helper...${RC}"
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git
cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/paru.git && "$ESCALATION_TOOL" chown -R "$USER": ./paru
cd paru && makepkg --noconfirm -si
cd /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/paru-bin.git && "$ESCALATION_TOOL" chown -R "$USER": ./paru-bin
cd paru-bin && makepkg --noconfirm -si
printf "%b\n" "${GREEN}Paru installed${RC}"
else
printf "%b\n" "${GREEN}Paru already installed${RC}"

View File

@ -216,7 +216,7 @@ echo -ne "
------------------------------------------------------------------------
THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK
Please make sure you know what you are doing because
after formating your disk there is no way to get data back
after formatting your disk there is no way to get data back
*****BACKUP YOUR DATA BEFORE CONTINUING*****
***I AM NOT RESPONSIBLE FOR ANY DATA LOSS***
------------------------------------------------------------------------
@ -328,7 +328,7 @@ echo -ne "
pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc
echo -ne "
-------------------------------------------------------------------------
Formating Disk
Formatting Disk
-------------------------------------------------------------------------
"
umount -A --recursive /mnt # make sure everything is unmounted before we start
@ -466,7 +466,7 @@ if [[ $TOTAL_MEM -lt 8000000 ]]; then
mkswap /mnt/opt/swap/swapfile
swapon /mnt/opt/swap/swapfile
# The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself.
echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation.
echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation.
fi
gpu_type=$(lspci | grep -E "VGA|3D|Display")
@ -493,8 +493,8 @@ nc=$(grep -c ^processor /proc/cpuinfo)
echo -ne "
-------------------------------------------------------------------------
You have " $nc" cores. And
changing the makeflags for " $nc" cores. Aswell as
changing the compression settings.
changing the makeflags for " $nc" cores. Aswell as
changing the compression settings.
-------------------------------------------------------------------------
"
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
@ -670,4 +670,4 @@ sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: A
# Add sudo rights
sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
EOF
EOF

View File

@ -15,30 +15,30 @@ installDepend() {
else
printf "%b\n" "${GREEN}Multilib is already enabled.${RC}"
fi
"$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES"
"$AUR_HELPER" -S --needed --noconfirm $DEPENDENCIES
;;
apt-get|nala)
COMPILEDEPS='build-essential'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" dpkg --add-architecture i386
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
;;
dnf)
COMPILEDEPS='@development-tools'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
;;
zypper)
COMPILEDEPS='patterns-devel-base-devel_basis'
"$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
;;
esac
}

View File

@ -10,7 +10,7 @@ configureDNF() {
echo "fastestmirror=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null
echo "defaultyes=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null
"$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core
printf "%b\n" "${GREEN}DNF Configured Succesfully...${RC}"
printf "%b\n" "${GREEN}DNF Configured Successfully.${RC}"
;;
*)
printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}"

View File

@ -0,0 +1,83 @@
#!/bin/sh -e
. ../../common-script.sh
current_version=$(rpm -E '%{fedora}')
next_version=$((current_version + 1))
update() {
printf "%b\n" "${YELLOW}Make sure your system is fully updated; if not, update it first and reboot once.${RC}"
printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}"
printf "%b\n" "${CYAN}The next available version is $next_version.${RC}"
printf "%b\n" "${YELLOW}Do you want to update to $next_version? (y/n): ${RC}"
read -r response
case "$response" in
y|Y)
printf "%b\n" "${CYAN}Preparing to update to $next_version...${RC}"
if ! "$ESCALATION_TOOL" "$PACKAGER" install dnf-plugin-system-upgrade -y; then
printf "%b\n" "${RED}Failed to install dnf-plugin-system-upgrade.${RC}"
exit 1
fi
if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version" -y ; then
printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}"
exit 1
fi
printf "%b\n" "${YELLOW}Do you want to reboot now to apply the upgrade? (y/n): ${RC}"
read -r reboot_response
case "$reboot_response" in
y|Y)
printf "%b\n" "${YELLOW}Rebooting to apply the upgrade...${RC}"
"$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot
;;
*)
printf "%b\n" "${YELLOW}You can reboot later to apply the upgrade.${RC}"
;;
esac
;;
*)
printf "%b\n" "${RED}No upgrade performed.${RC}"
;;
esac
}
post_upgrade() {
printf "%b\n" "${YELLOW}Running post-upgrade tasks...${RC}"
case "$PACKAGER" in
dnf)
"$ESCALATION_TOOL" "$PACKAGER" autoremove
"$ESCALATION_TOOL" "$PACKAGER" distro-sync -y
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER.${RC}"
exit 1
;;
esac
}
checkEnv
checkEscalationTool
printf "%b\n" "${YELLOW}Select an option:${RC}"
printf "%b\n" "${GREEN}1. Upgrade to the next Fedora version${RC}"
printf "%b\n" "${GREEN}2. Run post-upgrade tasks${RC}"
read -r choice
case "$choice" in
1)
update
;;
2)
post_upgrade
;;
*)
printf "%b\n" "${RED}Invalid option. Please select 1 or 2.${RC}"
exit 1
;;
esac

View File

@ -3,7 +3,7 @@
. ../../common-script.sh
# This script allows user to download proprietary drivers for nvidia in fedora
# It also disables noveau nvidia drivers
# It also disables nouveau nvidia drivers
# Installation guide link: https://rpmfusion.org/Howto/NVIDIA
@ -91,4 +91,4 @@ printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free reposit
checkEnv
checkEscalationTool
userConfirmation
userConfirmation

View File

@ -23,7 +23,7 @@ installDepend() {
ncurses lib32-ncurses vulkan-icd-loader lib32-vulkan-icd-loader ocl-icd lib32-ocl-icd libva lib32-libva \
gst-plugins-base-libs lib32-gst-plugins-base-libs sdl2"
$AUR_HELPER -S --needed --noconfirm "$DEPENDENCIES" "$DISTRO_DEPS"
$AUR_HELPER -S --needed --noconfirm $DEPENDENCIES $DISTRO_DEPS
;;
apt-get|nala)
DISTRO_DEPS="libasound2 libsdl2 wine64 wine32"
@ -33,24 +33,24 @@ installDepend() {
"$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common
"$ESCALATION_TOOL" apt-add-repository contrib -y
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$DISTRO_DEPS"
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS
;;
dnf)
if [ "$(rpm -E %fedora)" -le 41 ]; then
"$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
else
printf "%b\n" "${CYAN}Fedora < 41 detected. Installing rpmfusion repos.${RC}"
"$ESCALATION_TOOL" "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm -y
"$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 -y
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
fi
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" -n install "$DEPENDENCIES"
"$ESCALATION_TOOL" "$PACKAGER" -n install $DEPENDENCIES
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
;;
esac
}
@ -59,7 +59,7 @@ installAdditionalDepend() {
case "$PACKAGER" in
pacman)
DISTRO_DEPS='steam lutris goverlay'
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$DISTRO_DEPS"
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm $DISTRO_DEPS
;;
apt-get|nala)
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |

View File

@ -3,27 +3,29 @@
. ../common-script.sh
removeSnaps() {
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Rns snapd
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd
if [ "$ID" = ubuntu ]; then
"$ESCALATION_TOOL" apt-mark hold snapd
fi
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
if command_exists snap; then
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Rns snapd
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd
if [ "$ID" = ubuntu ]; then
"$ESCALATION_TOOL" apt-mark hold snapd
fi
;;
dnf|zypper)
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
printf "%b\n" "${GREEN}Successfully removed snaps.${RC}"
else
printf "%b\n" "${GREEN}Snapd is not installed.${RC}"
fi
}
checkEnv

29
core/tabs/system-setup/system-cleanup.sh Normal file → Executable file
View File

@ -7,10 +7,8 @@ cleanup_system() {
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" clean
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
"$ESCALATION_TOOL" "$PACKAGER" autoclean
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
"$ESCALATION_TOOL" du -h /var/cache/apt
"$ESCALATION_TOOL" "$PACKAGER" clean
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" clean -a
@ -23,19 +21,24 @@ cleanup_system() {
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
return 1
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}. Skipping.${RC}"
;;
esac
}
common_cleanup() {
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete
"$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
if [ -d /var/tmp ]; then
"$ESCALATION_TOOL" find /var/tmp -type f -atime +5 -delete
fi
if [ -d /tmp ]; then
"$ESCALATION_TOOL" find /tmp -type f -atime +5 -delete
fi
if [ -d /var/log ]; then
"$ESCALATION_TOOL" find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
fi
"$ESCALATION_TOOL" journalctl --vacuum-time=3d
}
@ -45,8 +48,12 @@ clean_data() {
case $clean_response in
y|Y)
printf "%b\n" "${YELLOW}Cleaning up old cache files and emptying trash...${RC}"
find "$HOME/.cache/" -type f -atime +5 -delete
find "$HOME/.local/share/Trash" -mindepth 1 -delete
if [ -d "$HOME/.cache" ]; then
find "$HOME/.cache/" -type f -atime +5 -delete
fi
if [ -d "$HOME/.local/share/Trash" ]; then
find "$HOME/.local/share/Trash" -mindepth 1 -delete
fi
printf "%b\n" "${GREEN}Cache and trash cleanup completed.${RC}"
;;
*)

View File

@ -59,6 +59,12 @@ description = "RPM Fusion provides software that the Fedora Project or Red Hat d
script = "fedora/rpm-fusion-setup.sh"
task_list = "MP"
[[data.entries]]
name = "Upgrade to a New Fedora Release"
description = "Upgrades system to the next Fedora release"
script = "fedora/fedora-upgrade.sh"
task_list = "MP"
[[data.entries]]
name = "Virtualization"
description = "Enables Virtualization through dnf"

View File

@ -2,12 +2,7 @@
. ../common-script.sh
# Function to display usage instructions
usage() {
printf "%b\n" "${RED} Usage: $0 ${RC}"
printf "%b\n" "No arguments needed. The script will prompt for ISO path and USB device."
exit 1
}
CONFIGURATION_URL="https://github.com/quickemu-project/quickget_configs/releases/download/daily/quickget_data.json"
# Function to display all available block devices
list_devices() {
@ -17,53 +12,23 @@ list_devices() {
printf "\n"
}
# Function to fetch the latest Arch Linux ISO
fetch_arch_latest_iso() {
ARCH_BASE_URL="https://archive.archlinux.org/iso/"
ARCH_LATEST=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V | tail -1)
ARCH_URL="${ARCH_BASE_URL}${ARCH_LATEST}/archlinux-${ARCH_LATEST}-x86_64.iso"
printf "%b\n" "${GREEN} Selected Arch Linux (latest) ISO URL: ${RC} $ARCH_URL"
}
# Function to fetch older Arch Linux ISOs and display in a table format
fetch_arch_older_isos() {
ARCH_BASE_URL="https://archive.archlinux.org/iso/"
ARCH_VERSIONS=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V)
# Filter versions to include only those from 2017-04-01 and later
MIN_DATE="2017.04.01"
ARCH_VERSIONS=$(echo "$ARCH_VERSIONS" | awk -v min_date="$MIN_DATE" '$0 >= min_date')
if [ -z "$ARCH_VERSIONS" ]; then
printf "%b\n" "${RED}No Arch Linux versions found from ${MIN_DATE} onwards.${RC}"
exit 1
installDependencies() {
DEPENDENCIES="xz gzip bzip2 jq"
if ! command_exists ${DEPENDENCIES}; then
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
case "${PACKAGER}" in
apt-get|nala)
"${ESCALATION_TOOL}" "${PACKAGER}" install -y xz-utils gzip bzip2 jq;;
dnf|zypper)
"${ESCALATION_TOOL}" "${PACKAGER}" install -y ${DEPENDENCIES};;
pacman)
"${ESCALATION_TOOL}" "${PACKAGER}" -S --noconfirm --needed ${DEPENDENCIES};;
*)
printf "%b\n" "${RED}Unsupported package manager.${RC}"
exit 1
;;
esac
fi
printf "%b\n" "${YELLOW}Available Arch Linux versions from ${MIN_DATE} onwards:${RC}"
COUNTER=1
ROW_ITEMS=6 # Number of versions to show per row
for VERSION in $ARCH_VERSIONS; do
printf "%-5s${YELLOW}%-15s ${RC}" "$COUNTER)" "$VERSION"
if [ $(( COUNTER % ROW_ITEMS )) -eq 0 ]; then
printf "\n" # New line after every 6 versions
fi
COUNTER=$((COUNTER + 1))
done
printf "\n" # New line after the last row
printf "%b" "Select an Arch Linux version (1-$((COUNTER - 1))): "
read -r ARCH_OPTION
ARCH_DIR=$(echo "$ARCH_VERSIONS" | sed -n "${ARCH_OPTION}p")
ARCH_URL="${ARCH_BASE_URL}${ARCH_DIR}/archlinux-${ARCH_DIR}-x86_64.iso"
printf "%b\n" "${GREEN}Selected Arch Linux (older) ISO URL: $ARCH_URL${RC}"
}
# Function to fetch the latest Debian Linux ISO
fetch_debian_latest_iso() {
DEBIAN_URL=$(curl -s https://www.debian.org/distrib/netinst | grep -oP '(?<=href=")[^"]+debian-[0-9.]+-amd64-netinst.iso(?=")' | head -1)
printf "%b\n" "${GREEN} Selected Debian Linux (latest) ISO URL: ${RC} $DEBIAN_URL"
}
# Function to ask whether to use local or online ISO
@ -77,7 +42,7 @@ choose_iso_source() {
case $ISO_SOURCE_OPTION in
1)
fetch_iso_urls # Call the function to fetch online ISO URLs
get_online_iso
;;
2)
printf "Enter the path to the already downloaded ISO file: "
@ -94,45 +59,156 @@ choose_iso_source() {
esac
}
# Function to fetch ISO URLs
fetch_iso_urls() {
clear
printf "%b\n" "${YELLOW}Available ISOs for download:${RC}"
printf "%b\n" "1) Arch Linux (latest)"
printf "%b\n" "2) Arch Linux (older versions)"
printf "%b\n" "3) Debian Linux (latest)"
printf "\n"
printf "%b" "Select the ISO you want to download (1-3): "
read -r ISO_OPTION
case $ISO_OPTION in
1)
fetch_arch_latest_iso
ISO_URL=$ARCH_URL
;;
2)
fetch_arch_older_isos
ISO_URL=$ARCH_URL
;;
3)
fetch_debian_latest_iso
ISO_URL=$DEBIAN_URL
;;
*)
printf "%b\n" "${RED}Invalid option selected.${RC}"
decompress_iso() {
printf "%b\n" "${YELLOW}Decompressing ISO file...${RC}"
case "${ISO_ARCHIVE_FORMAT}" in
xz)
xz -d "${ISO_PATH}"
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.xz//')";;
gz)
gzip -d "${ISO_PATH}"
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.gz//')";;
bz2)
bzip2 -d "${ISO_PATH}"
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.bz2//')";;
*)
printf "%b\n" "${RED}Unsupported archive format. Try manually decompressing the ISO and choosing it as a local file instead.${RC}"
exit 1
;;
esac
ISO_PATH=$(basename "$ISO_URL")
printf "%b\n" "${YELLOW}Downloading ISO...${RC}"
curl -L -o "$ISO_PATH" "$ISO_URL"
if [ $? -ne 0 ]; then
printf "%b\n" "${GREEN}ISO file decompressed successfully.${RC}"
}
check_hash() {
case "${#ISO_CHECKSUM}" in
32) HASH_ALGO="md5sum";;
40) HASH_ALGO="sha1sum";;
64) HASH_ALGO="sha256sum";;
128) HASH_ALGO="sha512sum";;
*) printf "%b\n" "${RED}Invalid checksum length. Skipping checksum verification.${RC}"
return;;
esac
printf "%b\n" "Checking ISO integrity using ${HASH_ALGO}..."
if ! echo "${ISO_CHECKSUM} ${ISO_PATH}" | "${HASH_ALGO}" --check --status; then
printf "%b\n" "${RED}Checksum verification failed.${RC}"
exit 1
else
printf "%b\n" "${GREEN}Checksum verification successful.${RC}"
fi
}
download_iso() {
printf "\n%b\n" "${YELLOW}Found URL: ${ISO_URL}${RC}"
printf "%b\n" "${YELLOW}Downloading ISO to ${ISO_PATH}...${RC}"
if ! curl -L -o "$ISO_PATH" "$ISO_URL"; then
printf "%b\n" "${RED}Failed to download the ISO file.${RC}"
exit 1
fi
}
get_architecture() {
printf "%b\n" "${YELLOW}Select the architecture of the ISO to flash${RC}"
printf "%b\n" "1) x86_64"
printf "%b\n" "2) AArch64"
printf "%b\n" "3) riscv64"
printf "%b" "Select an option (1-3): "
read -r ARCH
case "${ARCH}" in
1) ARCH="x86_64";;
2) ARCH="aarch64";;
3) ARCH="riscv64";;
*)
printf "%b\n" "${RED}Invalid architecture selected. ${RC}"
exit 1
;;
esac
}
comma_delimited_list() {
echo "${1}" | tr '\n' ',' | sed 's/,/, /g; s/, $//'
}
get_online_iso() {
get_architecture
printf "%b\n" "${YELLOW}Fetching available operating systems...${RC}"
clear
# Download available operating systems, filter to to those that match requirements
# Remove entries with more than 1 ISO or any other medium, they could cause issues
OS_JSON="$(curl -L -s "$CONFIGURATION_URL" | jq -c "[.[] | \
.releases |= map(select( \
(.arch // \"x86_64\") == "\"${ARCH}\"" \
and (.iso | length == 1) and (.iso[0] | has(\"web\")) \
and .img == null and .fixed_iso == null and .floppy == null and .disk_images == null)) \
| select(.releases | length > 0)]")"
if echo "${OS_JSON}" | jq -e 'length == 0' >/dev/null; then
printf "%b\n" "${RED}No operating systems found.${RC}"
exit 1
fi
printf "%b\n" "${YELLOW}Available Operating Systems:${RC}"
comma_delimited_list "$(echo "${OS_JSON}" | jq -r '.[].name')"
printf "\n%b" "Select an operating system: "
read -r OS
OS_JSON="$(echo "${OS_JSON}" | jq --arg os "${OS}" -c '.[] | select(.name == $os)')"
if [ -z "${OS_JSON}" ]; then
printf "%b\n" "${RED}Invalid operating system selected.${RC}"
exit 1
fi
PRETTY_NAME="$(echo "${OS_JSON}" | jq -r '.pretty_name')"
printf "\n%b\n" "${YELLOW}Available releases for ${PRETTY_NAME}:${RC}"
comma_delimited_list "$(echo "${OS_JSON}" | jq -r '.releases[].release' | sort -Vur)"
printf "\n%b" "Select a release: "
read -r RELEASE
printf "\n"
OS_JSON="$(echo "${OS_JSON}" | jq --arg release "${RELEASE}" -c '.releases |= map(select(.release == $release))')"
if echo "${OS_JSON}" | jq -e '.releases | length == 0' >/dev/null; then
printf "%b\n" "${RED}Invalid release selected.${RC}"
exit 1
fi
if echo "${OS_JSON}" | jq -e '.releases[] | select(.edition != null) | any' >/dev/null; then
printf "%b\n" "${YELLOW}Available editions for ${PRETTY_NAME} ${RELEASE}:${RC}"
comma_delimited_list "$(echo "${OS_JSON}" | jq -r '.releases[].edition' | sort -Vur)"
printf "\n%b" "Select an edition: "
read -r EDITION
ENTRY="$(echo "${OS_JSON}" | jq --arg edition "${EDITION}" -c '.releases[] | select(.edition == $edition)')"
else
ENTRY="$(echo "${OS_JSON}" | jq -c '.releases[0]')"
fi
if [ -z "${ENTRY}" ]; then
printf "%b\n" "${RED}Invalid edition selected.${RC}"
exit 1
fi
WEB_DATA="$(echo "${ENTRY}" | jq -c '.iso[0].web')"
ISO_URL="$(echo "${WEB_DATA}" | jq -r '.url')"
ISO_CHECKSUM="$(echo "${WEB_DATA}" | jq -r '.checksum')"
ISO_ARCHIVE_FORMAT="$(echo "${WEB_DATA}" | jq -r '.archive_format')"
ISO_FILENAME="$(echo "${WEB_DATA}" | jq -r '.file_name')"
if [ "${ISO_FILENAME}" = "null" ]; then
ISO_FILENAME="$(basename "${ISO_URL}")"
fi
ISO_PATH="${HOME}/Downloads/${ISO_FILENAME}"
download_iso
if [ "${ISO_CHECKSUM}" != "null" ]; then
check_hash
fi
if [ "${ISO_ARCHIVE_FORMAT}" != "null" ]; then
decompress_iso
fi
}
write_iso(){
clear
@ -191,4 +267,5 @@ write_iso(){
checkEnv
checkEscalationTool
write_iso
installDependencies
write_iso

View File

@ -13,7 +13,7 @@ change_orientation() {
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Change Monitor Orientation${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b" "${YELLOW}Choose a monitor to configure: ${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to configure: ${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${GREEN}$monitor${RC}"

View File

@ -13,7 +13,7 @@ disable_monitor() {
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Disable Monitor${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b" "Choose a monitor to disable: "
printf "%b\n" "Choose a monitor to disable: "
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${GREEN}$monitor${RC}"

View File

@ -13,7 +13,7 @@ enable_monitor() {
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Enable Monitor${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b" "${YELLOW}Choose a monitor to enable: ${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to enable: ${RC}"
i=1
for monitor in $monitor_array; do

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. ./utility_functions.sh
. ../utility_functions.sh
. ../../common-script.sh

View File

@ -13,10 +13,10 @@ manage_arrangement() {
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Manage Monitor Arrangement${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b" "${YELLOW}Choose the monitor to arrange: ${RC}"
printf "%b\n" "${YELLOW}Choose the monitor to arrange: ${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
i=$((i + 1))
done

12
core/tabs/utils/monitor-control/set_brightness.sh Normal file → Executable file
View File

@ -6,8 +6,6 @@
adjust_monitor_brightness() {
while true; do
monitor_list=$(detect_connected_monitors)
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
set -- "$monitor_array"
count=1
clear
@ -15,7 +13,7 @@ adjust_monitor_brightness() {
printf "%b\n" "${YELLOW} Adjust Monitor Brightness${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to adjust brightness:${RC}"
for monitor in "$@"; do
echo "$monitor_list" | while IFS= read -r monitor; do
echo "$count. $monitor"
count=$((count + 1))
done
@ -35,18 +33,18 @@ adjust_monitor_brightness() {
continue
fi
if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$#" ]; then
monitor_count=$(echo "$monitor_list" | wc -l)
if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$monitor_count" ]; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
printf "Press [Enter] to continue..."
read -r dummy
continue
fi
monitor_name=$(eval echo "\${$monitor_choice}")
monitor_name=$(echo "$monitor_list" | sed -n "${monitor_choice}p")
current_brightness=$(get_current_brightness "$monitor_name")
# Correctly calculate the brightness percentage
current_brightness_percentage=$(awk "BEGIN {printf \"%.0f\", $current_brightness * 100}")
current_brightness_percentage=$(awk -v brightness="$current_brightness" 'BEGIN {printf "%.0f", brightness * 100}')
printf "%b\n" "${YELLOW}Current brightness for $monitor_name${RC}: ${GREEN}$current_brightness_percentage%${RC}"
while true; do

View File

@ -16,7 +16,7 @@ set_primary_monitor() {
printf "%b\n" "${YELLOW}Choose a monitor to set as primary:${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
i=$((i + 1))
done

View File

@ -4,14 +4,15 @@
# Check if ~/.ssh/config exists, if not, create it
if [ ! -f ~/.ssh/config ]; then
touch ~/.ssh/config
chmod 600 ~/.ssh/config
mkdir -p "$HOME/.ssh"
touch "$HOME/.ssh/config"
chmod 600 "$HOME/.ssh/config"
fi
# Function to show available hosts from ~/.ssh/config
show_available_hosts() {
printf "%b\n" "Available Systems:"
grep -E "^Host " ~/.ssh/config | awk '{print $2}'
grep -E "^Host " "$HOME/.ssh/config" | awk '{print $2}'
printf "%b\n" "-------------------"
}

View File

@ -16,60 +16,66 @@ values = [":0", ":1", ":2", ":3", ":4", ":5", ":6", ":7", ":8", ":9"]
[[data.entries]]
name = "Auto Detect Displays"
description = "This utility is designed to detect and apply recommended configuration for monitors connected with your system"
description = "This script is designed to detect and apply recommended configuration for monitors connected with your system"
script = "monitor-control/auto_detect_displays.sh"
[[data.entries]]
name = "Change Orientation"
description = "This utility is designed to change the orientation of monitors in your system"
description = "This script is designed to change the orientation of monitors in your system"
script = "monitor-control/change_orientation.sh"
[[data.entries]]
name = "Disable Monitor"
description = "This utility is designed to disable a monitor in your system"
description = "This script is designed to disable a monitor in your system"
script = "monitor-control/disable_monitor.sh"
[[data.entries]]
name = "Duplicate Displays"
description = "This utility is designed to duplicate display among multi-monitor setup in your system"
description = "This script is designed to duplicate display among multi-monitor setup in your system"
script = "monitor-control/duplicate_displays.sh"
[[data.entries]]
name = "Enable Monitor"
description = "This utility is designed to enable a monitor in your system"
description = "This script is designed to enable a monitor in your system"
script = "monitor-control/enable_monitor.sh"
[[data.entries]]
name = "Extend Displays"
description = "This utility is designed to extend display among multi-monitor setup in your system"
description = "This script is designed to extend display among multi-monitor setup in your system"
script = "monitor-control/extend_displays.sh"
[[data.entries]]
name = "Manage Arrangement"
description = "This utility is designed to arrange monitors in multi-monitor setup in your system"
description = "This script is designed to arrange monitors in multi-monitor setup in your system"
script = "monitor-control/manage_arrangement.sh"
[[data.entries]]
name = "Reset Scaling"
description = "This utility is designed to reset scaling of a monitor in your system"
description = "This script is designed to reset scaling of a monitor in your system"
script = "monitor-control/reset_scaling.sh"
matches = true
[[data.entries]]
name = "Scale Monitors"
description = "This utility is designed to change the scaling of monitors in your system"
description = "This script is designed to change the scaling of monitors in your system"
script = "monitor-control/scale_monitor.sh"
[[data.entries]]
name = "Set Brightness"
script = "monitor-control/set_brightness.sh"
description = "This script is designed to change the Brightness of monitors connected to your system"
matches = true
[[data.entries]]
name = "Set Primary Monitor"
description = "This utility is designed to set a Primary monitor in your system"
description = "This script is designed to set a Primary monitor in your system"
script = "monitor-control/set_primary_monitor.sh"
[[data.entries]]
name = "Set Resolution"
description = "This script is designed to change the resolution of monitors connected to your system"
script = "monitor-control/set_resolutions.sh"
[[data]]
name = "User Account Manager"
multi_select = false
@ -161,6 +167,11 @@ name = "Timeshift Backup"
script = "timeshift.sh"
task_list = "I"
[[data.preconditions]]
matches = false
data = "command_exists"
values = [ "dnf" ]
[[data]]
name = "WiFi Manager"
description = "This utility is designed to manage wifi in your system"

View File

@ -61,13 +61,14 @@ Require linutil
Require sh
Set Shell "bash"
Set FontSize 32
Set Width 3200
Set Height 1800
Set FontFamily "JetBrainsMono Nerd Font"
Set FontSize 24
Set Width 1920
Set Height 1080
Sleep 1s
Type "linutil -t compatible" Sleep 1s Enter
Type "linutil" Sleep 1s Enter
Sleep 5s

View File

@ -1,4 +1,6 @@
# How to Contribute?
<!-- THIS FILE IS GENERATED AUTOMATICALLY. EDIT .github/CONTRIBUTING.md -->
# 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:
@ -16,6 +18,7 @@ cd linutil
```
## 3. Make your changes
- **Edit the files you want to change**: Make your changes to the relevant files.
- **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
@ -40,22 +43,29 @@ 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.
- **Automatic generation**: If you decide to add functionality through a new shell script, make sure to fill out all fields in `tab_data.toml` and run `cargo xtask docgen`.
## 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.

View File

@ -5,19 +5,23 @@
## Goals
- [ ] Focus on tasks that take time in Linux and automate them. (Example: Removing a user, adding a user, etc. - but mostly BASH scripts with POSIX compliance.)
- [ ] Remove Binary linutil from being tracked in git and make it a github action.
- [x] Remove Binary linutil from being tracked in git and make it a github action.
- [ ] Document every function and feature of linutil. (Preview panel description addition)
- [x] Create a discord server for linutil and invite the community.
- [ ] Power Optimizations for Laptops
- [x] Power Optimizations for Laptops
## Milestones
### Q3 2024
- [ ] Finish the foundation of the project in CLI mode.
- [ ] DENY ALL GUI Pull Requests while CLI and foundation is being established.
### Q4 2024
- [x] Finish the foundation of the project's CLI
- [ ] Implement CLI arguments and configuration support
- [ ] Add an option for logging script executions
### Q1 2025
- [ ] GUI Brainstorming and Planning
- [ ] GUI Implementation towards the end of Q4
- [ ] Basic GUI Implementation
### Q2 2025
- [ ] Full GUI Implementation
## Community Feedback
- Encourage community input and suggestions for future development.

View File

@ -1,81 +1,151 @@
<!-- THIS FILE IS GENERATED BY cargo xtask docgen -->
# 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 script is designed to detect and apply recommended configuration for monitors connected with your system
- **Change Orientation**: This script is designed to change the orientation of monitors in your system
- **Disable Monitor**: This script is designed to disable a monitor in your system
- **Duplicate Displays**: This script is designed to duplicate display among multi-monitor setup in your system
- **Enable Monitor**: This script is designed to enable a monitor in your system
- **Extend Displays**: This script is designed to extend display among multi-monitor setup in your system
- **Manage Arrangement**: This script is designed to arrange monitors in multi-monitor setup in your system
- **Reset Scaling**: This script is designed to reset scaling of a monitor in your system
- **Scale Monitors**: This script is designed to change the scaling of monitors in your system
- **Set Brightness**: This script is designed to change the Brightness of monitors connected to your system
- **Set Primary Monitor**: This script is designed to set a Primary monitor in your system
- **Set Resolution**: This script is designed to change the resolution of monitors connected to 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

View File

@ -1,7 +1,8 @@
[Desktop Entry]
Name=Linutil
Exec=sh -c "$HOME/.local/bin/linutil"
Comment=Distro-agnostic toolbox designed to simplify everyday Linux tasks
Exec=sh -c '/usr/bin/linutil || $HOME/.cargo/bin/linutil || linutil'
Icon=utilities-terminal
Type=Application
Terminal=true
Categories=Utility;
Categories=Utility;

65
man/linutil.1 Normal file
View File

@ -0,0 +1,65 @@
.\" manpage for Linutil
.TH "linutil" "1" "October 2024" "" "Linutil Manual"
.SH NAME
linutil \- Chris Titus Tech's Linux Toolbox
.SH SYNOPSIS
\fBlinutil [OPTIONS]\fR
.SH DESCRIPTION
Linutil is a distro-agnostic toolbox designed to simplify everyday Linux tasks.
.br
It helps you set up applications and optimize your system for specific use cases. The utility is actively developed in Rust, providing performance and reliability.
.SH LIVE VERSION
To get started with the live version, pick which branch you would like to use, then run the command in your terminal:
.TP
\fBStable Branch\fR
curl -fsSL https://christitus.com/linux | sh
.TP
\fBDevelopement branch\fR
curl -fsSL https://christitus.com/linuxdev | sh
.SH OPTIONS
.TP
\fB\-t\fR, \fB\-\-theme\fR \fI<theme>\fR
Set the theme to use in the TUI.
.br
Possible values:
\fIdefault\fR,
\fIcompatible\fR.
.br
Defaults to \fIdefault\fR.
.TP
\fB\-\-override\-validation\fR
Show all available entries, disregarding compatibility checks. (\fBUNSAFE\fR)
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help.
.SH SUPPORT
If you find Linutil helpful, please consider giving it a star on GitHub to show your support!
https://github.com/ChrisTitusTech/linutil
.SH DOCUMENTATION
For comprehensive information on how to use Linutil, visit the Official Linutil Documentation.
https://christitustech.github.io/linutil
.SH AUTHOR
Written by Adam Perkowski.
<adas1per@protonmail.com>
.SH REPORTING BUGS
Since the project is still in active development, you may encounter some issues.
.br
Please consider submitting feedback if you do.
https://github.com/ChrisTitusTech/linutil/issues
.SH COPYRIGHT
Copyright (c) 2024 Chris Titus.
.br
MIT License.
https://opensource.org/license/MIT

View File

@ -14,8 +14,8 @@ check() {
exit 1
fi
unset exit_code
unset message
unset exit_code
unset message
}
findArch() {

View File

@ -7,15 +7,14 @@ edition = "2021"
license.workspace = true
repository = "https://github.com/ChrisTitusTech/linutil/tree/main/tui"
version.workspace = true
include = ["src/*.rs", "Cargo.toml", "build.rs", "cool_tips.txt"]
build = "build.rs"
include = ["src/*.rs", "Cargo.toml", "cool_tips.txt", "../man/linutil.1"]
[features]
default = ["tips"]
tips = ["rand"]
[dependencies]
clap = { version = "4.5.18", features = ["derive"] }
clap = { version = "4.5.19", features = ["derive"] }
crossterm = "0.28.1"
ego-tree = { workspace = true }
oneshot = "0.1.8"
@ -26,15 +25,12 @@ temp-dir = "0.1.14"
unicode-width = "0.2.0"
rand = { version = "0.8.5", optional = true }
linutil_core = { path = "../core", version = "24.9.28" }
tree-sitter-highlight = "0.23.0"
tree-sitter-highlight = "0.24.2"
tree-sitter-bash = "0.23.1"
anstyle = "1.0.8"
ansi-to-tui = "6.0.0"
zips = "0.1.7"
[build-dependencies]
chrono = "0.4.33"
[[bin]]
name = "linutil"
path = "src/main.rs"

View File

@ -1,7 +0,0 @@
fn main() {
// Add current date as a variable to be displayed in the 'Linux Toolbox' text.
println!(
"cargo:rustc-env=BUILD_DATE={}",
chrono::Local::now().format("%Y-%m-%d")
);
}

View File

@ -88,7 +88,7 @@ impl FloatContent for ConfirmPrompt {
use KeyCode::*;
self.status = match key.code {
Char('y') | Char('Y') => ConfirmStatus::Confirm,
Char('n') | Char('N') | Esc => ConfirmStatus::Abort,
Char('n') | Char('N') | Esc | Char('q') => ConfirmStatus::Abort,
Char('j') => {
self.scroll_down();
ConfirmStatus::None
@ -116,10 +116,10 @@ impl FloatContent for ConfirmPrompt {
"Confirmation prompt",
Box::new([
Shortcut::new("Continue", ["Y", "y"]),
Shortcut::new("Abort", ["N", "n"]),
Shortcut::new("Scroll up", ["j"]),
Shortcut::new("Scroll down", ["k"]),
Shortcut::new("Close linutil", ["CTRL-c", "q"]),
Shortcut::new("Abort", ["N", "n", "q", "Esc"]),
Shortcut::new("Scroll up", ["k"]),
Shortcut::new("Scroll down", ["j"]),
Shortcut::new("Close linutil", ["CTRL-c"]),
]),
)
}

View File

@ -1,5 +1,5 @@
use crate::{state::ListEntry, theme::Theme};
use crossterm::event::{KeyCode, KeyEvent};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use ego_tree::NodeId;
use linutil_core::Tab;
use ratatui::{
@ -95,7 +95,7 @@ impl Filter {
//Create the search bar widget
let search_bar = Paragraph::new(display_text)
.block(Block::default().borders(Borders::ALL).title("Search"))
.block(Block::default().borders(Borders::ALL).title(" Search "))
.style(Style::default().fg(search_color));
//Render the search bar (First chunk of the screen)
@ -116,21 +116,27 @@ impl Filter {
pub fn handle_key(&mut self, event: &KeyEvent) -> SearchAction {
//Insert user input into the search bar
match event.code {
KeyCode::Char('c') if event.modifiers.contains(KeyModifiers::CONTROL) => {
return self.exit_search()
}
KeyCode::Char(c) => self.insert_char(c),
KeyCode::Backspace => self.remove_previous(),
KeyCode::Delete => self.remove_next(),
KeyCode::Left => return self.cursor_left(),
KeyCode::Right => return self.cursor_right(),
KeyCode::Esc => {
self.input_position = 0;
self.search_input.clear();
return SearchAction::Exit;
}
KeyCode::Enter => return SearchAction::Exit,
KeyCode::Esc => return self.exit_search(),
_ => return SearchAction::None,
};
SearchAction::Update
}
fn exit_search(&mut self) -> SearchAction {
self.input_position = 0;
self.search_input.clear();
SearchAction::Exit
}
fn cursor_left(&mut self) -> SearchAction {
self.input_position = self.input_position.saturating_sub(1);
SearchAction::None
@ -158,4 +164,8 @@ impl Filter {
self.search_input.remove(current);
}
}
pub fn clear_search(&mut self) {
self.search_input.clear();
self.input_position = 0;
}
}

View File

@ -24,18 +24,13 @@ use tree_sitter_bash as hl_bash;
use tree_sitter_highlight::{self as hl, HighlightEvent};
use zips::zip_result;
pub enum FloatingTextMode {
Preview,
Description,
ActionsGuide,
}
pub struct FloatingText {
pub src: Vec<String>,
max_line_width: usize,
v_scroll: usize,
h_scroll: usize,
mode_title: &'static str,
mode_title: String,
frame_height: usize,
}
macro_rules! style {
@ -130,7 +125,7 @@ fn get_lines_owned(s: &str) -> Vec<String> {
}
impl FloatingText {
pub fn new(text: String, mode: FloatingTextMode) -> Self {
pub fn new(text: String, title: &str) -> Self {
let src = get_lines(&text)
.into_iter()
.map(|s| s.to_string())
@ -139,14 +134,15 @@ impl FloatingText {
let max_line_width = max_width!(src);
Self {
src,
mode_title: Self::get_mode_title(mode),
mode_title: title.to_string(),
max_line_width,
v_scroll: 0,
h_scroll: 0,
frame_height: 0,
}
}
pub fn from_command(command: &Command, mode: FloatingTextMode) -> Option<Self> {
pub fn from_command(command: &Command, title: String) -> Option<Self> {
let (max_line_width, src) = match command {
Command::Raw(cmd) => {
// just apply highlights directly
@ -169,23 +165,17 @@ impl FloatingText {
Some(Self {
src,
mode_title: Self::get_mode_title(mode),
mode_title: title,
max_line_width,
h_scroll: 0,
v_scroll: 0,
frame_height: 0,
})
}
fn get_mode_title(mode: FloatingTextMode) -> &'static str {
match mode {
FloatingTextMode::Preview => "Command Preview",
FloatingTextMode::Description => "Command Description",
FloatingTextMode::ActionsGuide => "Important Actions Guide",
}
}
fn scroll_down(&mut self) {
if self.v_scroll + 1 < self.src.len() {
let visible_lines = self.frame_height.saturating_sub(2);
if self.v_scroll + visible_lines < self.src.len() {
self.v_scroll += 1;
}
}
@ -211,15 +201,18 @@ impl FloatingText {
impl FloatContent for FloatingText {
fn draw(&mut self, frame: &mut Frame, area: Rect) {
self.frame_height = area.height as usize;
// Define the Block with a border and background color
let block = Block::default()
.borders(Borders::ALL)
.title(self.mode_title)
.title(self.mode_title.clone())
.title_alignment(ratatui::layout::Alignment::Center)
.title_style(Style::default().reversed())
.style(Style::default());
// Draw the Block first
frame.render_widget(Clear, area);
frame.render_widget(block.clone(), area);
// Calculate the inner area to ensure text is not drawn over the border
@ -267,9 +260,6 @@ impl FloatContent for FloatingText {
.block(Block::default())
.highlight_style(Style::default().reversed());
// Clear the text underneath the floats rendered area
frame.render_widget(Clear, inner_area);
// Render the list inside the bordered area
frame.render_widget(list, inner_area);
}
@ -292,7 +282,7 @@ impl FloatContent for FloatingText {
fn get_shortcut_list(&self) -> (&str, Box<[Shortcut]>) {
(
self.mode_title,
&self.mode_title,
Box::new([
Shortcut::new("Scroll down", ["j", "Down"]),
Shortcut::new("Scroll up", ["k", "Up"]),

View File

@ -27,41 +27,33 @@ pub fn create_shortcut_list(
shortcuts: impl IntoIterator<Item = Shortcut>,
render_width: u16,
) -> Box<[Line<'static>]> {
let hints = shortcuts.into_iter().collect::<Box<[Shortcut]>>();
let shortcut_spans: Vec<Vec<Span<'static>>> =
shortcuts.into_iter().map(|h| h.to_spans()).collect();
let mut shortcut_spans: Vec<Vec<Span<'static>>> = hints.iter().map(|h| h.to_spans()).collect();
let max_shortcut_width = shortcut_spans
.iter()
.map(|s| span_vec_len(s))
.max()
.unwrap_or(0);
let mut lines: Vec<Line<'static>> = vec![];
let columns = (render_width as usize / (max_shortcut_width + 4)).max(1);
let rows = (shortcut_spans.len() + columns - 1) / columns;
loop {
let split_idx = shortcut_spans
.iter()
.scan(0usize, |total_len, s| {
// take at least one so that we guarantee that we drain the list
// otherwise, this might lock up if there's a shortcut that exceeds the window width
if *total_len == 0 {
*total_len += span_vec_len(s) + 4;
Some(())
} else {
*total_len += span_vec_len(s);
if *total_len > render_width as usize {
None
} else {
*total_len += 4;
Some(())
}
}
let mut lines: Vec<Line<'static>> = Vec::new();
for row in 0..rows {
let row_spans: Vec<_> = (0..columns)
.filter_map(|col| {
let index = row * columns + col;
shortcut_spans.get(index).map(|span| {
let padding = max_shortcut_width - span_vec_len(span);
let mut span_clone = span.clone();
span_clone.push(Span::raw(" ".repeat(padding)));
span_clone
})
})
.count();
let rest = shortcut_spans.split_off(split_idx);
lines.push(add_spacing(shortcut_spans));
if rest.is_empty() {
break;
} else {
shortcut_spans = rest;
}
.collect();
lines.push(add_spacing(row_spans));
}
lines.into_boxed_slice()

View File

@ -74,7 +74,7 @@ impl FloatContent for RunningCommand {
title_line.push_span(
Span::default()
.content(" press <ENTER> to close this window ")
.content(" Press <ENTER> to close this window ")
.style(Style::default()),
);

View File

@ -1,10 +1,8 @@
use std::rc::Rc;
use crate::{
confirmation::{ConfirmPrompt, ConfirmStatus},
filter::{Filter, SearchAction},
float::{Float, FloatContent},
floating_text::{FloatingText, FloatingTextMode},
floating_text::FloatingText,
hint::{create_shortcut_list, Shortcut},
running_command::RunningCommand,
theme::Theme,
@ -21,11 +19,12 @@ use ratatui::{
widgets::{Block, Borders, List, ListState, Paragraph},
Frame,
};
use std::rc::Rc;
use temp_dir::TempDir;
const MIN_WIDTH: u16 = 77;
const MIN_HEIGHT: u16 = 19;
const TITLE: &str = concat!("Linux Toolbox - ", env!("BUILD_DATE"));
const MIN_WIDTH: u16 = 100;
const MIN_HEIGHT: u16 = 25;
const TITLE: &str = concat!(" Linux Toolbox - ", env!("CARGO_PKG_VERSION"), " ");
const ACTIONS_GUIDE: &str = "List of important tasks performed by commands' names:
D - disk modifications (ex. partitioning) (privileged)
@ -53,8 +52,8 @@ pub struct AppState {
current_tab: ListState,
/// This stack keeps track of our "current directory". You can think of it as `pwd`. but not
/// just the current directory, all paths that took us here, so we can "cd .."
visit_stack: Vec<NodeId>,
/// This is the state asociated with the list widget, used to display the selection in the
visit_stack: Vec<(NodeId, usize)>,
/// This is the state associated with the list widget, used to display the selection in the
/// widget
selection: ListState,
filter: Filter,
@ -62,7 +61,7 @@ pub struct AppState {
selected_commands: Vec<Rc<ListNode>>,
drawable: bool,
#[cfg(feature = "tips")]
tip: &'static str,
tip: String,
}
pub enum Focus {
@ -79,6 +78,13 @@ pub struct ListEntry {
pub has_children: bool,
}
enum SelectedItem {
UpDir,
Directory,
Command,
None,
}
impl AppState {
pub fn new(theme: Theme, override_validation: bool) -> Self {
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
@ -90,7 +96,7 @@ impl AppState {
focus: Focus::List,
tabs,
current_tab: ListState::default().with_selected(Some(0)),
visit_stack: vec![root_id],
visit_stack: vec![(root_id, 0usize)],
selection: ListState::default().with_selected(Some(0)),
filter: Filter::new(),
multi_select: false,
@ -120,7 +126,10 @@ impl AppState {
match self.focus {
Focus::Search => (
"Search bar",
Box::new([Shortcut::new("Finish search", ["Enter"])]),
Box::new([
Shortcut::new("Abort search", ["Esc", "CTRL-c"]),
Shortcut::new("Search", ["Enter"]),
]),
),
Focus::List => {
@ -378,17 +387,17 @@ impl AppState {
};
let title = if self.multi_select {
&format!("{} [Multi-Select]", TITLE)
&format!("{}[Multi-Select] ", TITLE)
} else {
TITLE
};
#[cfg(feature = "tips")]
let bottom_title = Line::from(self.tip.bold().blue()).right_aligned();
let bottom_title = Line::from(self.tip.as_str().bold().blue()).right_aligned();
#[cfg(not(feature = "tips"))]
let bottom_title = "";
let task_list_title = Line::from("Important Actions ").right_aligned();
let task_list_title = Line::from(" Important Actions ").right_aligned();
// Create the list widget with items
let list = List::new(items)
@ -423,11 +432,15 @@ impl AppState {
// This should be defined first to allow closing
// the application even when not drawable ( If terminal is small )
// Exit on 'q' or 'Ctrl-c' input
if matches!(
self.focus,
Focus::TabList | Focus::List | Focus::ConfirmationPrompt(_)
) && (key.code == KeyCode::Char('q')
|| key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
if matches!(self.focus, Focus::TabList | Focus::List)
&& (key.code == KeyCode::Char('q')
|| key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
{
return false;
}
if matches!(self.focus, Focus::ConfirmationPrompt(_))
&& (key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
{
return false;
}
@ -501,17 +514,9 @@ impl AppState {
Focus::TabList => match key.code {
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.focus = Focus::List,
KeyCode::Char('j') | KeyCode::Down
if self.current_tab.selected().unwrap() + 1 < self.tabs.len() =>
{
self.current_tab.select_next();
self.refresh_tab();
}
KeyCode::Char('j') | KeyCode::Down => self.scroll_tab_down(),
KeyCode::Char('k') | KeyCode::Up => {
self.current_tab.select_previous();
self.refresh_tab();
}
KeyCode::Char('k') | KeyCode::Up => self.scroll_tab_up(),
KeyCode::Char('/') => self.enter_search(),
KeyCode::Char('t') => self.theme.next(),
@ -521,8 +526,8 @@ impl AppState {
},
Focus::List if key.kind != KeyEventKind::Release => match key.code {
KeyCode::Char('j') | KeyCode::Down => self.selection.select_next(),
KeyCode::Char('k') | KeyCode::Up => self.selection.select_previous(),
KeyCode::Char('j') | KeyCode::Down => self.scroll_down(),
KeyCode::Char('k') | KeyCode::Up => self.scroll_up(),
KeyCode::Char('p') | KeyCode::Char('P') => self.enable_preview(),
KeyCode::Char('d') | KeyCode::Char('D') => self.enable_description(),
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.handle_enter(),
@ -541,6 +546,34 @@ impl AppState {
true
}
fn scroll_down(&mut self) {
let len = self.filter.item_list().len();
if len == 0 {
return;
}
let current = self.selection.selected().unwrap_or(0);
let max_index = if self.at_root() { len - 1 } else { len };
let next = if current + 1 > max_index {
0
} else {
current + 1
};
self.selection.select(Some(next));
}
fn scroll_up(&mut self) {
let len = self.filter.item_list().len();
if len == 0 {
return;
}
let current = self.selection.selected().unwrap_or(0);
let max_index = if self.at_root() { len - 1 } else { len };
let next = if current == 0 { max_index } else { current - 1 };
self.selection.select(Some(next));
}
fn toggle_multi_select(&mut self) {
self.multi_select = !self.multi_select;
if !self.multi_select {
@ -564,8 +597,20 @@ impl AppState {
self.filter.update_items(
&self.tabs,
self.current_tab.selected().unwrap(),
*self.visit_stack.last().unwrap(),
self.visit_stack.last().unwrap().0,
);
if !self.is_current_tab_multi_selectable() {
self.multi_select = false;
self.selected_commands.clear();
}
let len = self.filter.item_list().len();
if len > 0 {
let current = self.selection.selected().unwrap_or(0);
self.selection.select(Some(current.min(len - 1)));
} else {
self.selection.select(None);
}
}
/// Checks either the current tree node is the root node (can we go up the tree or no)
@ -584,9 +629,10 @@ impl AppState {
}
fn enter_parent_directory(&mut self) {
self.visit_stack.pop();
self.selection.select(Some(0));
self.update_items();
if let Some((_, previous_position)) = self.visit_stack.pop() {
self.selection.select(Some(previous_position));
self.update_items();
}
}
fn get_selected_node(&self) -> Option<Rc<ListNode>> {
@ -613,20 +659,22 @@ impl AppState {
}
pub fn go_to_selected_dir(&mut self) {
let mut selected_index = self.selection.selected().unwrap_or(0);
let selected_index = self.selection.selected().unwrap_or(0);
if !self.at_root() && selected_index == 0 {
self.enter_parent_directory();
return;
}
if !self.at_root() {
selected_index = selected_index.saturating_sub(1);
}
let actual_index = if self.at_root() {
selected_index
} else {
selected_index - 1
};
if let Some(item) = self.filter.item_list().get(selected_index) {
if let Some(item) = self.filter.item_list().get(actual_index) {
if item.has_children {
self.visit_stack.push(item.id);
self.visit_stack.push((item.id, selected_index));
self.selection.select(Some(0));
self.update_items();
}
@ -658,15 +706,14 @@ impl AppState {
pub fn selected_item_is_up_dir(&self) -> bool {
let selected_index = self.selection.selected().unwrap_or(0);
!self.at_root() && selected_index == 0
}
fn enable_preview(&mut self) {
if let Some(node) = self.get_selected_node() {
if let Some(preview) =
FloatingText::from_command(&node.command, FloatingTextMode::Preview)
{
if let Some(list_node) = self.get_selected_node() {
let mut preview_title = "[Preview] - ".to_string();
preview_title.push_str(list_node.name.as_str());
if let Some(preview) = FloatingText::from_command(&list_node.command, preview_title) {
self.spawn_float(preview, 80, 80);
}
}
@ -674,29 +721,46 @@ impl AppState {
fn enable_description(&mut self) {
if let Some(command_description) = self.get_selected_description() {
let description = FloatingText::new(command_description, FloatingTextMode::Description);
self.spawn_float(description, 80, 80);
if !command_description.is_empty() {
let description = FloatingText::new(command_description, "Command Description");
self.spawn_float(description, 80, 80);
}
}
}
fn get_selected_item_type(&self) -> SelectedItem {
if self.selected_item_is_up_dir() {
SelectedItem::UpDir
} else if self.selected_item_is_dir() {
SelectedItem::Directory
} else if self.selected_item_is_cmd() {
SelectedItem::Command
} else {
SelectedItem::None
}
}
fn handle_enter(&mut self) {
if self.selected_item_is_cmd() {
if self.selected_commands.is_empty() {
if let Some(node) = self.get_selected_node() {
self.selected_commands.push(node);
match self.get_selected_item_type() {
SelectedItem::UpDir => self.enter_parent_directory(),
SelectedItem::Directory => self.go_to_selected_dir(),
SelectedItem::Command => {
if self.selected_commands.is_empty() {
if let Some(node) = self.get_selected_node() {
self.selected_commands.push(node);
}
}
let cmd_names = self
.selected_commands
.iter()
.map(|node| node.name.as_str())
.collect::<Vec<_>>();
let prompt = ConfirmPrompt::new(&cmd_names[..]);
self.focus = Focus::ConfirmationPrompt(Float::new(Box::new(prompt), 40, 40));
}
let cmd_names = self
.selected_commands
.iter()
.map(|node| node.name.as_str())
.collect::<Vec<_>>();
let prompt = ConfirmPrompt::new(&cmd_names[..]);
self.focus = Focus::ConfirmationPrompt(Float::new(Box::new(prompt), 40, 40));
} else {
self.go_to_selected_dir();
SelectedItem::None => {}
}
}
@ -730,34 +794,56 @@ impl AppState {
}
fn refresh_tab(&mut self) {
self.visit_stack = vec![self.tabs[self.current_tab.selected().unwrap()]
.tree
.root()
.id()];
self.visit_stack = vec![(
self.tabs[self.current_tab.selected().unwrap()]
.tree
.root()
.id(),
0usize,
)];
self.selection.select(Some(0));
self.filter.clear_search();
self.update_items();
}
fn toggle_task_list_guide(&mut self) {
self.spawn_float(
FloatingText::new(ACTIONS_GUIDE.to_string(), FloatingTextMode::ActionsGuide),
FloatingText::new(ACTIONS_GUIDE.to_string(), "Important Actions Guide"),
80,
80,
);
}
fn scroll_tab_down(&mut self) {
let len = self.tabs.len();
let current = self.current_tab.selected().unwrap_or(0);
let next = if current + 1 >= len { 0 } else { current + 1 };
self.current_tab.select(Some(next));
self.refresh_tab();
}
fn scroll_tab_up(&mut self) {
let len = self.tabs.len();
let current = self.current_tab.selected().unwrap_or(0);
let next = if current == 0 { len - 1 } else { current - 1 };
self.current_tab.select(Some(next));
self.refresh_tab();
}
}
#[cfg(feature = "tips")]
const TIPS: &str = include_str!("../cool_tips.txt");
#[cfg(feature = "tips")]
fn get_random_tip() -> &'static str {
fn get_random_tip() -> String {
let tips: Vec<&str> = TIPS.lines().collect();
if tips.is_empty() {
return "";
return "".to_string();
}
let mut rng = rand::thread_rng();
let random_index = rng.gen_range(0..tips.len());
tips[random_index]
format!(" {} ", tips[random_index])
}

8
xtask/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "xtask"
version.workspace = true
license.workspace = true
edition.workspace = true
[dependencies]
linutil_core = { path = "../core" }

60
xtask/src/docgen.rs Normal file
View File

@ -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<String, DynError> {
let mut md = String::new();
md.push_str("<!-- THIS FILE IS GENERATED BY cargo xtask docgen -->\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<details><summary>{}</summary>\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));
}

40
xtask/src/main.rs Normal file
View File

@ -0,0 +1,40 @@
mod docgen;
mod path;
use std::{env, error::Error};
type DynError = Box<dyn Error>;
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 <task>`
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(())
}

12
xtask/src/path.rs Normal file
View File

@ -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/")
}