mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-26 06:46:04 +00:00
Merge branch 'main' into alpine
This commit is contained in:
commit
7bdbbddd12
19
.github/SECURITY.md
vendored
19
.github/SECURITY.md
vendored
|
@ -2,13 +2,20 @@
|
||||||
|
|
||||||
## Supported Versions
|
## 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 |
|
| Branch | Supported |
|
||||||
| ------- | ------------------ |
|
| ------- | ---------------------- |
|
||||||
| latest | :white_check_mark: |
|
| Stable | :white_check_mark: YES |
|
||||||
| dev | :x: |
|
| 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
|
## 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).
|
||||||
|
|
32
.github/release.yml
vendored
32
.github/release.yml
vendored
|
@ -1,23 +1,35 @@
|
||||||
changelog:
|
changelog:
|
||||||
categories:
|
categories:
|
||||||
- title: '🚀 Features'
|
- title: '🚀 Features'
|
||||||
label: 'enhancement'
|
labels:
|
||||||
|
- 'enhancement'
|
||||||
- title: '🐛 Bug Fixes'
|
- title: '🐛 Bug Fixes'
|
||||||
label: 'bug'
|
labels:
|
||||||
|
- 'bug'
|
||||||
- title: '⚙️ Refactoring'
|
- title: '⚙️ Refactoring'
|
||||||
label: 'refactor'
|
labels:
|
||||||
|
- 'refactor'
|
||||||
- title: '🧩 UI/UX'
|
- title: '🧩 UI/UX'
|
||||||
label: 'UI/UX'
|
labels:
|
||||||
|
- 'UI/UX'
|
||||||
- title: '📚 Documentation'
|
- title: '📚 Documentation'
|
||||||
label: 'documentation'
|
labels:
|
||||||
|
- 'documentation'
|
||||||
- title: '🔒 Security'
|
- title: '🔒 Security'
|
||||||
label: 'security'
|
labels:
|
||||||
|
- 'security'
|
||||||
- title: '🧰 GitHub Actions'
|
- title: '🧰 GitHub Actions'
|
||||||
label: 'github_actions'
|
labels:
|
||||||
|
- 'github_actions'
|
||||||
- title: '🦀 Rust'
|
- title: '🦀 Rust'
|
||||||
label: 'rust'
|
labels:
|
||||||
|
- 'rust'
|
||||||
- title: '📃 Scripting'
|
- title: '📃 Scripting'
|
||||||
label: 'script'
|
labels:
|
||||||
|
- 'script'
|
||||||
|
- title: 'Other Changes'
|
||||||
|
labels:
|
||||||
|
- "*"
|
||||||
exclude:
|
exclude:
|
||||||
labels:
|
labels:
|
||||||
- 'skip-changelog'
|
- 'skip-changelog'
|
||||||
|
|
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
|
@ -5,7 +5,7 @@ on:
|
||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
paths:
|
paths:
|
||||||
- '**/*.rs'
|
- '**/*.rs'
|
||||||
- 'Cargo.toml'
|
- '**/Cargo.toml'
|
||||||
- 'Cargo.lock'
|
- 'Cargo.lock'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
|
61
.github/workflows/shellcheck.yml
vendored
61
.github/workflows/shellcheck.yml
vendored
|
@ -1,9 +1,9 @@
|
||||||
name: ShellCheck
|
name: Script Checks
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- 'core/tabs/**/*.sh'
|
- '**/*.sh'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -11,45 +11,24 @@ jobs:
|
||||||
name: Shellcheck
|
name: Shellcheck
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout sources
|
||||||
- run: git fetch origin ${{ github.base_ref }}
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download, setup, and run ShellCheck
|
- name: Run ShellCheck
|
||||||
shell: bash {0}
|
uses: reviewdog/action-shellcheck@v1
|
||||||
run : |
|
with:
|
||||||
SC_URL="https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz"
|
reviewdog_flags: '-fail-level=any'
|
||||||
curl -fsSL "$SC_URL" | tar -Jx
|
|
||||||
chmod +x "./shellcheck-v0.10.0/shellcheck"
|
|
||||||
|
|
||||||
error=0
|
shfmt:
|
||||||
files_to_check=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs)
|
name: Shell Fomatting
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: shellcheck
|
||||||
|
steps:
|
||||||
|
- name: Checkout sources
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
for file in $files_to_check; do
|
- name: Run shfmt
|
||||||
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then
|
uses: reviewdog/action-shfmt@v1
|
||||||
sc_output=$(./shellcheck-v0.10.0/shellcheck -fgcc -Serror "$file")
|
with:
|
||||||
iter_safe_parsed_errors=$(echo -e "$sc_output" | sed -n 's/\(.\+\)\:\([0-9]\+\)\:\([0-9]\+\)\: \(.*\)/::error file=\1,line=\2,col=\3::\4/p' | sed 's/ /:space:/g')
|
shfmt_flags: '-i 4 -ci'
|
||||||
|
reviewdog_flags: '-fail-level=any'
|
||||||
for error in $iter_safe_parsed_errors; do
|
|
||||||
echo "$error" | sed 's/:space:/ /g'
|
|
||||||
error=1
|
|
||||||
done
|
|
||||||
|
|
||||||
tabs_detected=$(grep -nP '^\t+\S+' "$file")
|
|
||||||
|
|
||||||
# fast fail on the action runner would fail immediately if there weren't any tabs found
|
|
||||||
# this check makes sure that we don't continue if there's something really weird going on
|
|
||||||
if [ "$?" = "2" ]; then
|
|
||||||
echo "::error file=$file::There was a critical error while grepping $file, aborting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
iter_safe_parsed_tabs_detected=$(echo "$tabs_detected" | sed -n 's,\([0-9]\+\).*,::error file='"$file"'\,line=\1::Found tab indentations,p' | sed 's/ /:space:/g')
|
|
||||||
|
|
||||||
for error in $iter_safe_parsed_tabs_detected; do
|
|
||||||
echo "$error" | sed 's/:space:/ /g'
|
|
||||||
error=1
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
exit $error
|
|
||||||
|
|
25
core/tabs/applications-setup/browsers/waterfox.sh
Normal file
25
core/tabs/applications-setup/browsers/waterfox.sh
Normal 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
|
|
@ -5,19 +5,19 @@
|
||||||
gitpath="$HOME/.local/share/mybash"
|
gitpath="$HOME/.local/share/mybash"
|
||||||
|
|
||||||
installDepend() {
|
installDepend() {
|
||||||
if ! command_exists bash bash-completion tar bat tree unzip fontconfig git; then
|
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}"
|
printf "%b\n" "${YELLOW}Installing Bash...${RC}"
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
pacman)
|
pacman)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig git
|
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig git
|
||||||
;;
|
;;
|
||||||
apk)
|
apk)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" add bash bash-completion tar bat tree unzip fontconfig git
|
"$ESCALATION_TOOL" "$PACKAGER" add bash bash-completion tar bat tree unzip fontconfig git
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig git
|
"$ESCALATION_TOOL" "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig git
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installFreeOffice() {
|
installFreeOffice() {
|
||||||
if ! command_exists softmaker-freeoffice-2024 freeoffice softmaker; then
|
if ! command_exists softmaker-freeoffice-2024 freeoffice softmaker; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installLibreOffice() {
|
installLibreOffice() {
|
||||||
if ! command_exists libreoffice; then
|
if ! command_exists libreoffice; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installOnlyOffice() {
|
installOnlyOffice() {
|
||||||
if ! command_exists onlyoffice-desktopeditors; then
|
if ! command_exists onlyoffice-desktopeditors; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installWpsOffice() {
|
installWpsOffice() {
|
||||||
if ! command_exists com.wps.Office; then
|
if ! command_exists com.wps.Office; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installEvince() {
|
installEvince() {
|
||||||
if ! command_exists evince; then
|
if ! command_exists evince; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installOkular() {
|
installOkular() {
|
||||||
if ! command_exists okular; then
|
if ! command_exists okular; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installPdfstudio() {
|
installPdfstudio() {
|
||||||
if ! command_exists pdfstudio2024; then
|
if ! command_exists pdfstudio2024; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installPdfstudioviewer() {
|
installPdfstudioviewer() {
|
||||||
if ! command_exists pdfstudioviewer2024; then
|
if ! command_exists pdfstudioviewer2024; then
|
||||||
|
|
|
@ -1,50 +1,5 @@
|
||||||
name = "Applications Setup"
|
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]]
|
[[data]]
|
||||||
name = "Communication Apps"
|
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"
|
script = "communication-apps/telegram-setup.sh"
|
||||||
task_list = "I"
|
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]]
|
[[data.entries]]
|
||||||
name = "Thunderbird"
|
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."
|
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"
|
script = "communication-apps/thunderbird-setup.sh"
|
||||||
task_list = "I"
|
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]]
|
[[data]]
|
||||||
name = "Office Suites"
|
name = "Office Suites"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "FreeOffice"
|
||||||
|
script = "office-suites/freeoffice.sh"
|
||||||
|
task_list = "I"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "LibreOffice"
|
name = "LibreOffice"
|
||||||
script = "office-suites/libreoffice.sh"
|
script = "office-suites/libreoffice.sh"
|
||||||
|
@ -103,11 +108,6 @@ name = "OnlyOffice"
|
||||||
script = "office-suites/onlyoffice.sh"
|
script = "office-suites/onlyoffice.sh"
|
||||||
task_list = "I"
|
task_list = "I"
|
||||||
|
|
||||||
[[data.entries]]
|
|
||||||
name = "FreeOffice"
|
|
||||||
script = "office-suites/freeoffice.sh"
|
|
||||||
task_list = "I"
|
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "WPS Office"
|
name = "WPS Office"
|
||||||
script = "office-suites/wpsoffice.sh"
|
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"
|
script = "browsers/vivaldi.sh"
|
||||||
task_list = "I"
|
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]]
|
[[data]]
|
||||||
name = "Alacritty"
|
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."
|
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"
|
script = "bottles-setup.sh"
|
||||||
task_list = "FI"
|
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]]
|
[[data]]
|
||||||
name = "Docker"
|
name = "Docker"
|
||||||
description = "Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers."
|
description = "Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers."
|
||||||
script = "docker-setup.sh"
|
script = "docker-setup.sh"
|
||||||
task_list = "I SS"
|
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]]
|
[[data]]
|
||||||
name = "Fastfetch"
|
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"
|
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"
|
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."
|
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"
|
script = "zsh-setup.sh"
|
||||||
task_list = "I FM"
|
task_list = "I FM"
|
|
@ -15,10 +15,17 @@ installWaydroid() {
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
pacman)
|
pacman)
|
||||||
"$AUR_HELPER" -S --needed --noconfirm waydroid
|
"$AUR_HELPER" -S --needed --noconfirm waydroid
|
||||||
if command_exists dkms; then
|
if ! command_exists dkms; then
|
||||||
"$AUR_HELPER" -S --needed --noconfirm binder_linux-dkms
|
installed_kernels=$("$PACKAGER" -Q | grep -E '^linux(| |-rt|-rt-lts|-hardened|-zen|-lts)[^-headers]' | cut -d ' ' -f 1)
|
||||||
"$ESCALATION_TOOL" modprobe binder-linux device=binder,hwbinder,vndbinder
|
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
|
fi
|
||||||
|
"$AUR_HELPER" -S --needed --noconfirm binder_linux-dkms
|
||||||
|
"$ESCALATION_TOOL" modprobe binder-linux device=binder,hwbinder,vndbinder
|
||||||
;;
|
;;
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
curl https://repo.waydro.id | "$ESCALATION_TOOL" sh
|
curl https://repo.waydro.id | "$ESCALATION_TOOL" sh
|
||||||
|
|
|
@ -9,7 +9,10 @@ CYAN='\033[36m'
|
||||||
GREEN='\033[32m'
|
GREEN='\033[32m'
|
||||||
|
|
||||||
command_exists() {
|
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() {
|
checkAURHelper() {
|
||||||
|
|
|
@ -8,8 +8,8 @@ installDepend() {
|
||||||
if ! command_exists paru; then
|
if ! command_exists paru; then
|
||||||
printf "%b\n" "${YELLOW}Installing paru as AUR helper...${RC}"
|
printf "%b\n" "${YELLOW}Installing paru as AUR helper...${RC}"
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel git
|
"$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 /opt && "$ESCALATION_TOOL" git clone https://aur.archlinux.org/paru-bin.git && "$ESCALATION_TOOL" chown -R "$USER": ./paru-bin
|
||||||
cd paru && makepkg --noconfirm -si
|
cd paru-bin && makepkg --noconfirm -si
|
||||||
printf "%b\n" "${GREEN}Paru installed${RC}"
|
printf "%b\n" "${GREEN}Paru installed${RC}"
|
||||||
else
|
else
|
||||||
printf "%b\n" "${GREEN}Paru already installed${RC}"
|
printf "%b\n" "${GREEN}Paru already installed${RC}"
|
||||||
|
|
83
core/tabs/system-setup/fedora/fedora-upgrade.sh
Normal file
83
core/tabs/system-setup/fedora/fedora-upgrade.sh
Normal 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
|
|
@ -8,10 +8,8 @@ cleanup_system() {
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" clean
|
"$ESCALATION_TOOL" "$PACKAGER" clean
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
|
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" autoclean
|
|
||||||
"$ESCALATION_TOOL" du -h /var/cache/apt
|
"$ESCALATION_TOOL" du -h /var/cache/apt
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" clean
|
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" clean -a
|
"$ESCALATION_TOOL" "$PACKAGER" clean -a
|
||||||
|
|
|
@ -59,6 +59,12 @@ description = "RPM Fusion provides software that the Fedora Project or Red Hat d
|
||||||
script = "fedora/rpm-fusion-setup.sh"
|
script = "fedora/rpm-fusion-setup.sh"
|
||||||
task_list = "MP"
|
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]]
|
[[data.entries]]
|
||||||
name = "Virtualization"
|
name = "Virtualization"
|
||||||
description = "Enables Virtualization through dnf"
|
description = "Enables Virtualization through dnf"
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
|
|
||||||
. ../common-script.sh
|
. ../common-script.sh
|
||||||
|
|
||||||
# Function to display usage instructions
|
CONFIGURATION_URL="https://github.com/quickemu-project/quickget_configs/releases/download/daily/quickget_data.json"
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to display all available block devices
|
# Function to display all available block devices
|
||||||
list_devices() {
|
list_devices() {
|
||||||
|
@ -17,53 +12,23 @@ list_devices() {
|
||||||
printf "\n"
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to fetch the latest Arch Linux ISO
|
installDependencies() {
|
||||||
fetch_arch_latest_iso() {
|
DEPENDENCIES="xz gzip bzip2 jq"
|
||||||
ARCH_BASE_URL="https://archive.archlinux.org/iso/"
|
if ! command_exists ${DEPENDENCIES}; then
|
||||||
ARCH_LATEST=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V | tail -1)
|
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
|
||||||
ARCH_URL="${ARCH_BASE_URL}${ARCH_LATEST}/archlinux-${ARCH_LATEST}-x86_64.iso"
|
case "${PACKAGER}" in
|
||||||
printf "%b\n" "${GREEN} Selected Arch Linux (latest) ISO URL: ${RC} $ARCH_URL"
|
apt-get|nala)
|
||||||
}
|
"${ESCALATION_TOOL}" "${PACKAGER}" install -y xz-utils gzip bzip2 jq;;
|
||||||
|
dnf|zypper)
|
||||||
# Function to fetch older Arch Linux ISOs and display in a table format
|
"${ESCALATION_TOOL}" "${PACKAGER}" install -y ${DEPENDENCIES};;
|
||||||
fetch_arch_older_isos() {
|
pacman)
|
||||||
ARCH_BASE_URL="https://archive.archlinux.org/iso/"
|
"${ESCALATION_TOOL}" "${PACKAGER}" -S --noconfirm --needed ${DEPENDENCIES};;
|
||||||
ARCH_VERSIONS=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V)
|
*)
|
||||||
|
printf "%b\n" "${RED}Unsupported package manager.${RC}"
|
||||||
# Filter versions to include only those from 2017-04-01 and later
|
exit 1
|
||||||
MIN_DATE="2017.04.01"
|
;;
|
||||||
ARCH_VERSIONS=$(echo "$ARCH_VERSIONS" | awk -v min_date="$MIN_DATE" '$0 >= min_date')
|
esac
|
||||||
|
|
||||||
if [ -z "$ARCH_VERSIONS" ]; then
|
|
||||||
printf "%b\n" "${RED}No Arch Linux versions found from ${MIN_DATE} onwards.${RC}"
|
|
||||||
exit 1
|
|
||||||
fi
|
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
|
# Function to ask whether to use local or online ISO
|
||||||
|
@ -77,7 +42,7 @@ choose_iso_source() {
|
||||||
|
|
||||||
case $ISO_SOURCE_OPTION in
|
case $ISO_SOURCE_OPTION in
|
||||||
1)
|
1)
|
||||||
fetch_iso_urls # Call the function to fetch online ISO URLs
|
get_online_iso
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
printf "Enter the path to the already downloaded ISO file: "
|
printf "Enter the path to the already downloaded ISO file: "
|
||||||
|
@ -94,45 +59,156 @@ choose_iso_source() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to fetch ISO URLs
|
decompress_iso() {
|
||||||
fetch_iso_urls() {
|
printf "%b\n" "${YELLOW}Decompressing ISO file...${RC}"
|
||||||
clear
|
case "${ISO_ARCHIVE_FORMAT}" in
|
||||||
printf "%b\n" "${YELLOW}Available ISOs for download:${RC}"
|
xz)
|
||||||
printf "%b\n" "1) Arch Linux (latest)"
|
xz -d "${ISO_PATH}"
|
||||||
printf "%b\n" "2) Arch Linux (older versions)"
|
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.xz//')";;
|
||||||
printf "%b\n" "3) Debian Linux (latest)"
|
gz)
|
||||||
printf "\n"
|
gzip -d "${ISO_PATH}"
|
||||||
printf "%b" "Select the ISO you want to download (1-3): "
|
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.gz//')";;
|
||||||
read -r ISO_OPTION
|
bz2)
|
||||||
|
bzip2 -d "${ISO_PATH}"
|
||||||
case $ISO_OPTION in
|
ISO_PATH="$(echo "${ISO_PATH}" | sed 's/\.bz2//')";;
|
||||||
1)
|
*)
|
||||||
fetch_arch_latest_iso
|
printf "%b\n" "${RED}Unsupported archive format. Try manually decompressing the ISO and choosing it as a local file instead.${RC}"
|
||||||
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}"
|
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
ISO_PATH=$(basename "$ISO_URL")
|
printf "%b\n" "${GREEN}ISO file decompressed successfully.${RC}"
|
||||||
printf "%b\n" "${YELLOW}Downloading ISO...${RC}"
|
}
|
||||||
curl -L -o "$ISO_PATH" "$ISO_URL"
|
|
||||||
if [ $? -ne 0 ]; then
|
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}"
|
printf "%b\n" "${RED}Failed to download the ISO file.${RC}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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(){
|
write_iso(){
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
@ -191,4 +267,5 @@ write_iso(){
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
checkEscalationTool
|
checkEscalationTool
|
||||||
write_iso
|
installDependencies
|
||||||
|
write_iso
|
||||||
|
|
12
core/tabs/utils/monitor-control/set_brightness.sh
Normal file → Executable file
12
core/tabs/utils/monitor-control/set_brightness.sh
Normal file → Executable file
|
@ -6,8 +6,6 @@
|
||||||
adjust_monitor_brightness() {
|
adjust_monitor_brightness() {
|
||||||
while true; do
|
while true; do
|
||||||
monitor_list=$(detect_connected_monitors)
|
monitor_list=$(detect_connected_monitors)
|
||||||
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
|
|
||||||
set -- "$monitor_array"
|
|
||||||
count=1
|
count=1
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
@ -15,7 +13,7 @@ adjust_monitor_brightness() {
|
||||||
printf "%b\n" "${YELLOW} Adjust Monitor Brightness${RC}"
|
printf "%b\n" "${YELLOW} Adjust Monitor Brightness${RC}"
|
||||||
printf "%b\n" "${YELLOW}=========================================${RC}"
|
printf "%b\n" "${YELLOW}=========================================${RC}"
|
||||||
printf "%b\n" "${YELLOW}Choose a monitor to adjust brightness:${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"
|
echo "$count. $monitor"
|
||||||
count=$((count + 1))
|
count=$((count + 1))
|
||||||
done
|
done
|
||||||
|
@ -35,18 +33,18 @@ adjust_monitor_brightness() {
|
||||||
continue
|
continue
|
||||||
fi
|
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 "%b\n" "${RED}Invalid selection. Please try again.${RC}"
|
||||||
printf "Press [Enter] to continue..."
|
printf "Press [Enter] to continue..."
|
||||||
read -r dummy
|
read -r dummy
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
monitor_name=$(eval echo "\${$monitor_choice}")
|
monitor_name=$(echo "$monitor_list" | sed -n "${monitor_choice}p")
|
||||||
current_brightness=$(get_current_brightness "$monitor_name")
|
current_brightness=$(get_current_brightness "$monitor_name")
|
||||||
|
|
||||||
# Correctly calculate the brightness percentage
|
current_brightness_percentage=$(awk -v brightness="$current_brightness" 'BEGIN {printf "%.0f", brightness * 100}')
|
||||||
current_brightness_percentage=$(awk "BEGIN {printf \"%.0f\", $current_brightness * 100}")
|
|
||||||
printf "%b\n" "${YELLOW}Current brightness for $monitor_name${RC}: ${GREEN}$current_brightness_percentage%${RC}"
|
printf "%b\n" "${YELLOW}Current brightness for $monitor_name${RC}: ${GREEN}$current_brightness_percentage%${RC}"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
|
@ -4,14 +4,15 @@
|
||||||
|
|
||||||
# Check if ~/.ssh/config exists, if not, create it
|
# Check if ~/.ssh/config exists, if not, create it
|
||||||
if [ ! -f ~/.ssh/config ]; then
|
if [ ! -f ~/.ssh/config ]; then
|
||||||
touch ~/.ssh/config
|
mkdir -p "$HOME/.ssh"
|
||||||
chmod 600 ~/.ssh/config
|
touch "$HOME/.ssh/config"
|
||||||
|
chmod 600 "$HOME/.ssh/config"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Function to show available hosts from ~/.ssh/config
|
# Function to show available hosts from ~/.ssh/config
|
||||||
show_available_hosts() {
|
show_available_hosts() {
|
||||||
printf "%b\n" "Available Systems:"
|
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" "-------------------"
|
printf "%b\n" "-------------------"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,11 @@ name = "Timeshift Backup"
|
||||||
script = "timeshift.sh"
|
script = "timeshift.sh"
|
||||||
task_list = "I"
|
task_list = "I"
|
||||||
|
|
||||||
|
[[data.preconditions]]
|
||||||
|
matches = false
|
||||||
|
data = "command_exists"
|
||||||
|
values = [ "dnf" ]
|
||||||
|
|
||||||
[[data]]
|
[[data]]
|
||||||
name = "WiFi Manager"
|
name = "WiFi Manager"
|
||||||
description = "This utility is designed to manage wifi in your system"
|
description = "This utility is designed to manage wifi in your system"
|
||||||
|
|
|
@ -5,19 +5,23 @@
|
||||||
|
|
||||||
## Goals
|
## 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.)
|
- [ ] 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)
|
- [ ] Document every function and feature of linutil. (Preview panel description addition)
|
||||||
- [x] Create a discord server for linutil and invite the community.
|
- [x] Create a discord server for linutil and invite the community.
|
||||||
- [ ] Power Optimizations for Laptops
|
- [x] Power Optimizations for Laptops
|
||||||
|
|
||||||
## Milestones
|
## 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
|
### 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 Brainstorming and Planning
|
||||||
- [ ] GUI Implementation towards the end of Q4
|
- [ ] Basic GUI Implementation
|
||||||
|
|
||||||
|
### Q2 2025
|
||||||
|
- [ ] Full GUI Implementation
|
||||||
|
|
||||||
## Community Feedback
|
## Community Feedback
|
||||||
- Encourage community input and suggestions for future development.
|
- Encourage community input and suggestions for future development.
|
||||||
|
|
|
@ -7,8 +7,7 @@ edition = "2021"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
repository = "https://github.com/ChrisTitusTech/linutil/tree/main/tui"
|
repository = "https://github.com/ChrisTitusTech/linutil/tree/main/tui"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
include = ["src/*.rs", "Cargo.toml", "build.rs", "cool_tips.txt", "../man/linutil.1"]
|
include = ["src/*.rs", "Cargo.toml", "cool_tips.txt", "../man/linutil.1"]
|
||||||
build = "build.rs"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["tips"]
|
default = ["tips"]
|
||||||
|
@ -32,9 +31,6 @@ anstyle = "1.0.8"
|
||||||
ansi-to-tui = "6.0.0"
|
ansi-to-tui = "6.0.0"
|
||||||
zips = "0.1.7"
|
zips = "0.1.7"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
chrono = "0.4.33"
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "linutil"
|
name = "linutil"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
|
@ -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")
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -88,7 +88,7 @@ impl FloatContent for ConfirmPrompt {
|
||||||
use KeyCode::*;
|
use KeyCode::*;
|
||||||
self.status = match key.code {
|
self.status = match key.code {
|
||||||
Char('y') | Char('Y') => ConfirmStatus::Confirm,
|
Char('y') | Char('Y') => ConfirmStatus::Confirm,
|
||||||
Char('n') | Char('N') | Esc => ConfirmStatus::Abort,
|
Char('n') | Char('N') | Esc | Char('q') => ConfirmStatus::Abort,
|
||||||
Char('j') => {
|
Char('j') => {
|
||||||
self.scroll_down();
|
self.scroll_down();
|
||||||
ConfirmStatus::None
|
ConfirmStatus::None
|
||||||
|
@ -116,10 +116,10 @@ impl FloatContent for ConfirmPrompt {
|
||||||
"Confirmation prompt",
|
"Confirmation prompt",
|
||||||
Box::new([
|
Box::new([
|
||||||
Shortcut::new("Continue", ["Y", "y"]),
|
Shortcut::new("Continue", ["Y", "y"]),
|
||||||
Shortcut::new("Abort", ["N", "n"]),
|
Shortcut::new("Abort", ["N", "n", "q", "Esc"]),
|
||||||
Shortcut::new("Scroll up", ["j"]),
|
Shortcut::new("Scroll up", ["k"]),
|
||||||
Shortcut::new("Scroll down", ["k"]),
|
Shortcut::new("Scroll down", ["j"]),
|
||||||
Shortcut::new("Close linutil", ["CTRL-c", "q"]),
|
Shortcut::new("Close linutil", ["CTRL-c"]),
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,4 +164,8 @@ impl Filter {
|
||||||
self.search_input.remove(current);
|
self.search_input.remove(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub fn clear_search(&mut self) {
|
||||||
|
self.search_input.clear();
|
||||||
|
self.input_position = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ pub struct FloatingText {
|
||||||
v_scroll: usize,
|
v_scroll: usize,
|
||||||
h_scroll: usize,
|
h_scroll: usize,
|
||||||
mode_title: String,
|
mode_title: String,
|
||||||
|
frame_height: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! style {
|
macro_rules! style {
|
||||||
|
@ -137,6 +138,7 @@ impl FloatingText {
|
||||||
max_line_width,
|
max_line_width,
|
||||||
v_scroll: 0,
|
v_scroll: 0,
|
||||||
h_scroll: 0,
|
h_scroll: 0,
|
||||||
|
frame_height: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +169,13 @@ impl FloatingText {
|
||||||
max_line_width,
|
max_line_width,
|
||||||
h_scroll: 0,
|
h_scroll: 0,
|
||||||
v_scroll: 0,
|
v_scroll: 0,
|
||||||
|
frame_height: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scroll_down(&mut self) {
|
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;
|
self.v_scroll += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,6 +201,8 @@ impl FloatingText {
|
||||||
|
|
||||||
impl FloatContent for FloatingText {
|
impl FloatContent for FloatingText {
|
||||||
fn draw(&mut self, frame: &mut Frame, area: Rect) {
|
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
|
// Define the Block with a border and background color
|
||||||
let block = Block::default()
|
let block = Block::default()
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
|
@ -205,7 +211,8 @@ impl FloatContent for FloatingText {
|
||||||
.title_style(Style::default().reversed())
|
.title_style(Style::default().reversed())
|
||||||
.style(Style::default());
|
.style(Style::default());
|
||||||
|
|
||||||
// Draw the Block first
|
frame.render_widget(Clear, area);
|
||||||
|
|
||||||
frame.render_widget(block.clone(), area);
|
frame.render_widget(block.clone(), area);
|
||||||
|
|
||||||
// Calculate the inner area to ensure text is not drawn over the border
|
// Calculate the inner area to ensure text is not drawn over the border
|
||||||
|
@ -253,9 +260,6 @@ impl FloatContent for FloatingText {
|
||||||
.block(Block::default())
|
.block(Block::default())
|
||||||
.highlight_style(Style::default().reversed());
|
.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
|
// Render the list inside the bordered area
|
||||||
frame.render_widget(list, inner_area);
|
frame.render_widget(list, inner_area);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,41 +27,33 @@ pub fn create_shortcut_list(
|
||||||
shortcuts: impl IntoIterator<Item = Shortcut>,
|
shortcuts: impl IntoIterator<Item = Shortcut>,
|
||||||
render_width: u16,
|
render_width: u16,
|
||||||
) -> Box<[Line<'static>]> {
|
) -> 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 mut lines: Vec<Line<'static>> = Vec::new();
|
||||||
let split_idx = shortcut_spans
|
|
||||||
.iter()
|
for row in 0..rows {
|
||||||
.scan(0usize, |total_len, s| {
|
let row_spans: Vec<_> = (0..columns)
|
||||||
// take at least one so that we guarantee that we drain the list
|
.filter_map(|col| {
|
||||||
// otherwise, this might lock up if there's a shortcut that exceeds the window width
|
let index = row * columns + col;
|
||||||
if *total_len == 0 {
|
shortcut_spans.get(index).map(|span| {
|
||||||
*total_len += span_vec_len(s) + 4;
|
let padding = max_shortcut_width - span_vec_len(span);
|
||||||
Some(())
|
let mut span_clone = span.clone();
|
||||||
} else {
|
span_clone.push(Span::raw(" ".repeat(padding)));
|
||||||
*total_len += span_vec_len(s);
|
span_clone
|
||||||
if *total_len > render_width as usize {
|
})
|
||||||
None
|
|
||||||
} else {
|
|
||||||
*total_len += 4;
|
|
||||||
Some(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.count();
|
.collect();
|
||||||
|
lines.push(add_spacing(row_spans));
|
||||||
let rest = shortcut_spans.split_off(split_idx);
|
|
||||||
lines.push(add_spacing(shortcut_spans));
|
|
||||||
|
|
||||||
if rest.is_empty() {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
shortcut_spans = rest;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.into_boxed_slice()
|
lines.into_boxed_slice()
|
||||||
|
|
187
tui/src/state.rs
187
tui/src/state.rs
|
@ -22,9 +22,9 @@ use ratatui::{
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use temp_dir::TempDir;
|
use temp_dir::TempDir;
|
||||||
|
|
||||||
const MIN_WIDTH: u16 = 77;
|
const MIN_WIDTH: u16 = 100;
|
||||||
const MIN_HEIGHT: u16 = 19;
|
const MIN_HEIGHT: u16 = 25;
|
||||||
const TITLE: &str = concat!("Linux Toolbox - ", env!("BUILD_DATE"));
|
const TITLE: &str = concat!("Linux Toolbox - ", env!("CARGO_PKG_VERSION"));
|
||||||
const ACTIONS_GUIDE: &str = "List of important tasks performed by commands' names:
|
const ACTIONS_GUIDE: &str = "List of important tasks performed by commands' names:
|
||||||
|
|
||||||
D - disk modifications (ex. partitioning) (privileged)
|
D - disk modifications (ex. partitioning) (privileged)
|
||||||
|
@ -52,7 +52,7 @@ pub struct AppState {
|
||||||
current_tab: ListState,
|
current_tab: ListState,
|
||||||
/// This stack keeps track of our "current directory". You can think of it as `pwd`. but not
|
/// 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 .."
|
/// just the current directory, all paths that took us here, so we can "cd .."
|
||||||
visit_stack: Vec<NodeId>,
|
visit_stack: Vec<(NodeId, usize)>,
|
||||||
/// This is the state associated with the list widget, used to display the selection in the
|
/// This is the state associated with the list widget, used to display the selection in the
|
||||||
/// widget
|
/// widget
|
||||||
selection: ListState,
|
selection: ListState,
|
||||||
|
@ -78,6 +78,13 @@ pub struct ListEntry {
|
||||||
pub has_children: bool,
|
pub has_children: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SelectedItem {
|
||||||
|
UpDir,
|
||||||
|
Directory,
|
||||||
|
Command,
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
pub fn new(theme: Theme, override_validation: bool) -> Self {
|
pub fn new(theme: Theme, override_validation: bool) -> Self {
|
||||||
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
|
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
|
||||||
|
@ -89,7 +96,7 @@ impl AppState {
|
||||||
focus: Focus::List,
|
focus: Focus::List,
|
||||||
tabs,
|
tabs,
|
||||||
current_tab: ListState::default().with_selected(Some(0)),
|
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)),
|
selection: ListState::default().with_selected(Some(0)),
|
||||||
filter: Filter::new(),
|
filter: Filter::new(),
|
||||||
multi_select: false,
|
multi_select: false,
|
||||||
|
@ -413,11 +420,15 @@ impl AppState {
|
||||||
// This should be defined first to allow closing
|
// This should be defined first to allow closing
|
||||||
// the application even when not drawable ( If terminal is small )
|
// the application even when not drawable ( If terminal is small )
|
||||||
// Exit on 'q' or 'Ctrl-c' input
|
// Exit on 'q' or 'Ctrl-c' input
|
||||||
if matches!(
|
if matches!(self.focus, Focus::TabList | Focus::List)
|
||||||
self.focus,
|
&& (key.code == KeyCode::Char('q')
|
||||||
Focus::TabList | Focus::List | Focus::ConfirmationPrompt(_)
|
|| key.modifiers.contains(KeyModifiers::CONTROL) && key.code == KeyCode::Char('c'))
|
||||||
) && (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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -484,17 +495,9 @@ impl AppState {
|
||||||
Focus::TabList => match key.code {
|
Focus::TabList => match key.code {
|
||||||
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.focus = Focus::List,
|
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.focus = Focus::List,
|
||||||
|
|
||||||
KeyCode::Char('j') | KeyCode::Down
|
KeyCode::Char('j') | KeyCode::Down => self.scroll_tab_down(),
|
||||||
if self.current_tab.selected().unwrap() + 1 < self.tabs.len() =>
|
|
||||||
{
|
|
||||||
self.current_tab.select_next();
|
|
||||||
self.refresh_tab();
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyCode::Char('k') | KeyCode::Up => {
|
KeyCode::Char('k') | KeyCode::Up => self.scroll_tab_up(),
|
||||||
self.current_tab.select_previous();
|
|
||||||
self.refresh_tab();
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyCode::Char('/') => self.enter_search(),
|
KeyCode::Char('/') => self.enter_search(),
|
||||||
KeyCode::Char('t') => self.theme.next(),
|
KeyCode::Char('t') => self.theme.next(),
|
||||||
|
@ -504,8 +507,8 @@ impl AppState {
|
||||||
},
|
},
|
||||||
|
|
||||||
Focus::List if key.kind != KeyEventKind::Release => match key.code {
|
Focus::List if key.kind != KeyEventKind::Release => match key.code {
|
||||||
KeyCode::Char('j') | KeyCode::Down => self.selection.select_next(),
|
KeyCode::Char('j') | KeyCode::Down => self.scroll_down(),
|
||||||
KeyCode::Char('k') | KeyCode::Up => self.selection.select_previous(),
|
KeyCode::Char('k') | KeyCode::Up => self.scroll_up(),
|
||||||
KeyCode::Char('p') | KeyCode::Char('P') => self.enable_preview(),
|
KeyCode::Char('p') | KeyCode::Char('P') => self.enable_preview(),
|
||||||
KeyCode::Char('d') | KeyCode::Char('D') => self.enable_description(),
|
KeyCode::Char('d') | KeyCode::Char('D') => self.enable_description(),
|
||||||
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.handle_enter(),
|
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right => self.handle_enter(),
|
||||||
|
@ -524,6 +527,34 @@ impl AppState {
|
||||||
true
|
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) {
|
fn toggle_multi_select(&mut self) {
|
||||||
if self.is_current_tab_multi_selectable() {
|
if self.is_current_tab_multi_selectable() {
|
||||||
self.multi_select = !self.multi_select;
|
self.multi_select = !self.multi_select;
|
||||||
|
@ -554,12 +585,19 @@ impl AppState {
|
||||||
self.filter.update_items(
|
self.filter.update_items(
|
||||||
&self.tabs,
|
&self.tabs,
|
||||||
self.current_tab.selected().unwrap(),
|
self.current_tab.selected().unwrap(),
|
||||||
*self.visit_stack.last().unwrap(),
|
self.visit_stack.last().unwrap().0,
|
||||||
);
|
);
|
||||||
if !self.is_current_tab_multi_selectable() {
|
if !self.is_current_tab_multi_selectable() {
|
||||||
self.multi_select = false;
|
self.multi_select = false;
|
||||||
self.selected_commands.clear();
|
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)
|
/// Checks either the current tree node is the root node (can we go up the tree or no)
|
||||||
|
@ -578,9 +616,10 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enter_parent_directory(&mut self) {
|
fn enter_parent_directory(&mut self) {
|
||||||
self.visit_stack.pop();
|
if let Some((_, previous_position)) = self.visit_stack.pop() {
|
||||||
self.selection.select(Some(0));
|
self.selection.select(Some(previous_position));
|
||||||
self.update_items();
|
self.update_items();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_selected_node(&self) -> Option<Rc<ListNode>> {
|
fn get_selected_node(&self) -> Option<Rc<ListNode>> {
|
||||||
|
@ -607,20 +646,22 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn go_to_selected_dir(&mut self) {
|
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 {
|
if !self.at_root() && selected_index == 0 {
|
||||||
self.enter_parent_directory();
|
self.enter_parent_directory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.at_root() {
|
let actual_index = if self.at_root() {
|
||||||
selected_index = selected_index.saturating_sub(1);
|
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 {
|
if item.has_children {
|
||||||
self.visit_stack.push(item.id);
|
self.visit_stack.push((item.id, selected_index));
|
||||||
self.selection.select(Some(0));
|
self.selection.select(Some(0));
|
||||||
self.update_items();
|
self.update_items();
|
||||||
}
|
}
|
||||||
|
@ -652,7 +693,6 @@ impl AppState {
|
||||||
|
|
||||||
pub fn selected_item_is_up_dir(&self) -> bool {
|
pub fn selected_item_is_up_dir(&self) -> bool {
|
||||||
let selected_index = self.selection.selected().unwrap_or(0);
|
let selected_index = self.selection.selected().unwrap_or(0);
|
||||||
|
|
||||||
!self.at_root() && selected_index == 0
|
!self.at_root() && selected_index == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,29 +708,46 @@ impl AppState {
|
||||||
|
|
||||||
fn enable_description(&mut self) {
|
fn enable_description(&mut self) {
|
||||||
if let Some(command_description) = self.get_selected_description() {
|
if let Some(command_description) = self.get_selected_description() {
|
||||||
let description = FloatingText::new(command_description, "Command Description");
|
if !command_description.is_empty() {
|
||||||
self.spawn_float(description, 80, 80);
|
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) {
|
fn handle_enter(&mut self) {
|
||||||
if self.selected_item_is_cmd() {
|
match self.get_selected_item_type() {
|
||||||
if self.selected_commands.is_empty() {
|
SelectedItem::UpDir => self.enter_parent_directory(),
|
||||||
if let Some(node) = self.get_selected_node() {
|
SelectedItem::Directory => self.go_to_selected_dir(),
|
||||||
self.selected_commands.push(node);
|
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));
|
||||||
}
|
}
|
||||||
|
SelectedItem::None => {}
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,11 +781,15 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn refresh_tab(&mut self) {
|
fn refresh_tab(&mut self) {
|
||||||
self.visit_stack = vec![self.tabs[self.current_tab.selected().unwrap()]
|
self.visit_stack = vec![(
|
||||||
.tree
|
self.tabs[self.current_tab.selected().unwrap()]
|
||||||
.root()
|
.tree
|
||||||
.id()];
|
.root()
|
||||||
|
.id(),
|
||||||
|
0usize,
|
||||||
|
)];
|
||||||
self.selection.select(Some(0));
|
self.selection.select(Some(0));
|
||||||
|
self.filter.clear_search();
|
||||||
self.update_items();
|
self.update_items();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,6 +800,24 @@ impl AppState {
|
||||||
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")]
|
#[cfg(feature = "tips")]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user