Merge branch 'main' into Changed-docs-repo

This commit is contained in:
hubster-bot 2024-11-01 21:17:58 +00:00
commit f332467f14
42 changed files with 561 additions and 389 deletions

BIN
.github/preview.gif vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -3,7 +3,7 @@ name: Check for bashisms
on: on:
pull_request: pull_request:
paths: paths:
- core/tabs/** - 'core/tabs/**/*.sh'
merge_group: merge_group:
workflow_dispatch: workflow_dispatch:
@ -15,31 +15,33 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: git fetch origin ${{ github.base_ref }} - run: git fetch origin ${{ github.base_ref }}
- name: Get a list of changed script files
id: get_sh_files
run: |
sh_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs | grep '\.sh$' || true)
if [ -n "$sh_files" ]; then
echo "$sh_files" > changed_files
echo "changed=1" >> $GITHUB_OUTPUT
else
echo "changed=0" >> $GITHUB_OUTPUT
fi
- name: Install devscripts - name: Install devscripts
if: steps.get_sh_files.outputs.changed == 1 run: sudo apt-get update && sudo apt-get install -y devscripts
run: sudo apt-get update && sudo apt-get install devscripts
- name: Get changed .sh files (PR only)
id: changed-sh-files
if: github.event_name == 'pull_request'
uses: tj-actions/changed-files@v45
with:
files: '**/*.sh'
- name: Get all .sh files (if workflow dispatched)
id: sh-files
if: github.event_name != 'pull_request'
run: |
files=$(find . -type f -name "*.sh" | tr '\n' ' ')
echo "files=${files:-none}" >> $GITHUB_ENV
- name: Set FILES for bashism check
id: set-files
run: |
if [[ "${{ steps.changed-sh-files.outputs.any_changed }}" == 'true' ]]; then
echo "FILES=${{ steps.changed-sh-files.outputs.all_changed_files }}" >> $GITHUB_ENV
else
echo "FILES=${{ env.files }}" >> $GITHUB_ENV
fi
- name: Check for bashisms - name: Check for bashisms
if: steps.get_sh_files.outputs.changed == 1
run: | run: |
echo "Running for:\n$(cat changed_files)\n" IFS=' ' read -r -a file_array <<< "$FILES"
for file in $(cat changed_files); do checkbashisms "${file_array[@]}"
if [[ -f "$file" ]]; then
checkbashisms "$file"
fi
done
- name: Remove the created file
if: steps.get_sh_files.outputs.changed == 1
run: rm changed_files

View File

@ -46,19 +46,9 @@ jobs:
run: cargo build --target-dir=build --release --verbose --target=x86_64-unknown-linux-musl --all-features run: cargo build --target-dir=build --release --verbose --target=x86_64-unknown-linux-musl --all-features
- name: Build aarch64 binary - name: Build aarch64 binary
run: cross build --target-dir=build --release --verbose --target=aarch64-unknown-linux-musl --all-features
- name: Move binaries to build directory
run: | run: |
mv build/x86_64-unknown-linux-musl/release/linutil build/linutil cross build --target-dir=build --release --verbose --target=aarch64-unknown-linux-musl --all-features
mv build/aarch64-unknown-linux-musl/release/linutil build/linutil-aarch64 mv ./build/aarch64-unknown-linux-musl/release/linutil ./build/aarch64-unknown-linux-musl/release/linutil-aarch64
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Commit Linutil
file_pattern: "build/linutil build/linutil-aarch64"
add_options: '--force'
if: success()
- name: Extract Version - name: Extract Version
id: extract_version id: extract_version
@ -80,32 +70,11 @@ jobs:
append_body: true append_body: true
generate_release_notes: true generate_release_notes: true
files: | files: |
./build/linutil ./build/x86_64-unknown-linux-musl/release/linutil
./build/linutil-aarch64 ./build/aarch64-unknown-linux-musl/release/linutil-aarch64
./start.sh ./start.sh
./startdev.sh ./startdev.sh
prerelease: true prerelease: true
env: env:
version: ${{ env.version }} version: ${{ env.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Preview
run: |
echo "$(pwd)/build" >> $GITHUB_PATH
- name: Generate preview
uses: charmbracelet/vhs-action@v2.1.0
with:
path: ".github/preview.tape"
- name: Move preview
run: |
mv preview.gif .github/preview.gif
- name: Upload preview
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Preview for ${{ env.version }}
file_pattern: ".github/preview.gif"
add_options: "--force"
if: success()

78
.github/workflows/preview.yml vendored Normal file
View File

@ -0,0 +1,78 @@
name: LinUtil Preview
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name'
required: true
workflow_run:
workflows: ["LinUtil Release"]
types:
- completed
jobs:
generate_preview:
runs-on: ubuntu-latest
environment: linutil_env
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Get tag name ( Workflow Run )
id: latest_tag
uses: actions/github-script@v7
if: github.event_name == 'workflow_run'
with:
script: |
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 1
});
core.setOutput('result', releases.data[0].tag_name);
result-encoding: string
- name: Set tag name ( Workflow Run )
if: github.event_name == 'workflow_run'
run: echo "tag_name=${{ steps.latest_tag.outputs.result }}" >> $GITHUB_ENV
- name: Set tag name ( Workflow Dispatch )
if: ${{ github.event_name }} == 'workflow_dispatch'
run: echo "tag_name=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- name: Download binary
run: |
curl -LO "https://github.com/${{ github.repository }}/releases/download/${{ env.tag_name }}/linutil"
- name: Set env
run: |
chmod +x linutil
mkdir -p build
mv linutil build/linutil
echo "${{ github.workspace }}/build" >> $GITHUB_PATH
- name: Generate preview
uses: charmbracelet/vhs-action@v2.1.0
with:
path: "docs/assets/preview.tape"
- name: Move preview
run: mv preview.gif docs/assets/preview.gif
- name: Create PR
uses: peter-evans/create-pull-request@v7.0.5
with:
commit-message: Preview for ${{ env.tag_name }}
file-pattern: "docs/assets/preview.gif"
add-options: "--force"
token: ${{ secrets.PAT_TOKEN }}
branch: feature/preview-${{ env.tag_name }}
title: "Update preview for ${{ env.tag_name }}"
body: |
Automated PR to update preview gif for version ${{ env.tag_name }}
if: success()

View File

@ -17,6 +17,7 @@ jobs:
- name: Run ShellCheck - name: Run ShellCheck
uses: reviewdog/action-shellcheck@v1 uses: reviewdog/action-shellcheck@v1
with: with:
shellcheck_flags: '--source-path=${{ github.workspace }}/.shellcheckrc'
reviewdog_flags: '-fail-level=any' reviewdog_flags: '-fail-level=any'
shfmt: shfmt:

View File

@ -12,4 +12,4 @@ jobs:
- run: git fetch origin ${{ github.base_ref }} - run: git fetch origin ${{ github.base_ref }}
- name: Run spellcheck - name: Run spellcheck
uses: crate-ci/typos@v1.25.0 uses: crate-ci/typos@v1.26.0

2
.shellcheckrc Normal file
View File

@ -0,0 +1,2 @@
external-sources=true
source=core/tabs/common-script.sh

185
Cargo.lock generated
View File

@ -29,26 +29,11 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "ansi-to-tui" name = "ansi-to-tui"
version = "6.0.0" version = "7.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00c4af0bef1b514c9b6a32a773caf604c1390fa7913f4eaa23bfe76f251d6a42" checksum = "67555e1f1ece39d737e28c8a017721287753af3f93225e4a445b29ccb0f5912c"
dependencies = [ dependencies = [
"nom", "nom",
"ratatui", "ratatui",
@ -136,12 +121,6 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bumpalo"
version = "3.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
[[package]] [[package]]
name = "byteorder" name = "byteorder"
version = "1.5.0" version = "1.5.0"
@ -178,25 +157,11 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.19" version = "4.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615" checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -204,9 +169,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.19" version = "4.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b" checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -252,12 +217,6 @@ dependencies = [
"static_assertions", "static_assertions",
] ]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]] [[package]]
name = "crossterm" name = "crossterm"
version = "0.28.1" version = "0.28.1"
@ -370,29 +329,6 @@ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]]
name = "iana-time-zone"
version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "include_dir" name = "include_dir"
version = "0.7.4" version = "0.7.4"
@ -422,6 +358,12 @@ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]]
name = "indoc"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
[[package]] [[package]]
name = "instability" name = "instability"
version = "0.3.2" version = "0.3.2"
@ -462,15 +404,6 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]]
name = "js-sys"
version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.5.0" version = "1.5.0"
@ -501,7 +434,6 @@ version = "24.9.28"
dependencies = [ dependencies = [
"ansi-to-tui", "ansi-to-tui",
"anstyle", "anstyle",
"chrono",
"clap", "clap",
"crossterm", "crossterm",
"ego-tree", "ego-tree",
@ -607,15 +539,6 @@ dependencies = [
"minimal-lexical", "minimal-lexical",
] ]
[[package]]
name = "num-traits"
version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.19.0" version = "1.19.0"
@ -743,23 +666,23 @@ dependencies = [
[[package]] [[package]]
name = "ratatui" name = "ratatui"
version = "0.28.1" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdef7f9be5c0122f890d58bdf4d964349ba6a6161f705907526d891efabba57d" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"cassowary", "cassowary",
"compact_str", "compact_str",
"crossterm", "crossterm",
"indoc",
"instability", "instability",
"itertools", "itertools",
"lru", "lru",
"paste", "paste",
"strum", "strum",
"strum_macros",
"unicode-segmentation", "unicode-segmentation",
"unicode-truncate", "unicode-truncate",
"unicode-width 0.1.14", "unicode-width 0.2.0",
] ]
[[package]] [[package]]
@ -1088,9 +1011,9 @@ dependencies = [
[[package]] [[package]]
name = "tree-sitter" name = "tree-sitter"
version = "0.24.2" version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b84f60031bf8245b563a80c92c1034e557a914f7958f474bc0afa2eed78b98" checksum = "f9871f16d6cf5c4757dcf30d5d2172a2df6987c510c017bbb7abfb7f9aa24d06"
dependencies = [ dependencies = [
"cc", "cc",
"regex", "regex",
@ -1111,9 +1034,9 @@ dependencies = [
[[package]] [[package]]
name = "tree-sitter-highlight" name = "tree-sitter-highlight"
version = "0.24.2" version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c727fb31f816c09fc54dc0e971d101318926866f7261b2acb820e84a61bf52d" checksum = "48859aa39513716018d81904220960f415dbb72e071234a721304d20bf245e4c"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"regex", "regex",
@ -1130,9 +1053,9 @@ checksum = "2545046bd1473dac6c626659cc2567c6c0ff302fc8b84a56c4243378276f7f57"
[[package]] [[package]]
name = "tui-term" name = "tui-term"
version = "0.1.13" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07f0233f0d4795d2dc6663cfc3ce56b87bebcee66d6bcc088aa6aff5c072361" checksum = "72af159125ce32b02ceaced6cffae6394b0e6b6dfd4dc164a6c59a2db9b3c0b0"
dependencies = [ dependencies = [
"ratatui", "ratatui",
"vt100", "vt100",
@ -1223,61 +1146,6 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]] [[package]]
name = "which" name = "which"
version = "6.0.3" version = "6.0.3"
@ -1312,15 +1180,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.52.0" version = "0.52.0"

View File

@ -0,0 +1,48 @@
#!/bin/sh -e
. ../../common-script.sh
manualInstall() {
JETBRAINS_TOOLBOX_DIR="/opt/jetbrains-toolbox"
case "$ARCH" in
x86_64) ARCHIVE_URL=$(curl -s "https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release" | jq -r ".TBA[0].downloads.linux.link") ;;
aarch64) ARCHIVE_URL=$(curl -s "https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release" | jq -r ".TBA[0].downloads.linuxARM64.link") ;;
esac
curl -fSL "$ARCHIVE_URL" -o "jetbrains-toolbox.tar.gz"
if [ -d "$JETBRAINS_TOOLBOX_DIR" ]; then
"$ESCALATION_TOOL" rm -rf "$JETBRAINS_TOOLBOX_DIR"
fi
"$ESCALATION_TOOL" mkdir -p "$JETBRAINS_TOOLBOX_DIR"
"$ESCALATION_TOOL" tar -xzf "jetbrains-toolbox.tar.gz" -C "$JETBRAINS_TOOLBOX_DIR" --strip-components=1
"$ESCALATION_TOOL" ln -sf "$JETBRAINS_TOOLBOX_DIR/jetbrains-toolbox" "/usr/bin/jetbrains-toolbox"
}
installJetBrainsToolBox() {
if ! command_exists jetbrains-toolbox; then
printf "%b\n" "${YELLOW}Installing Jetbrains Toolbox...${RC}"
case "$PACKAGER" in
pacman)
"$AUR_HELPER" -S --needed --noconfirm jetbrains-toolbox
;;
dnf)
manualInstall
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y libfuse2
manualInstall
;;
esac
printf "%b\n" "${GREEN}Successfully installed Jetbrains Toolbox.${RC}"
else
printf "%b\n" "${GREEN}Jetbrains toolbox is already installed.${RC}"
fi
}
checkEnv
checkEscalationTool
checkAURHelper
installJetBrainsToolBox

View File

@ -3,7 +3,7 @@
. ../../common-script.sh . ../../common-script.sh
installMeld() { installMeld() {
if ! command_exists meld; then if ! command_exists org.gnome.meld && ! command_exists meld; then
printf "%b\n" "${YELLOW}Installing Meld...${RC}" printf "%b\n" "${YELLOW}Installing Meld...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
pacman) pacman)
@ -13,7 +13,7 @@ installMeld() {
"$ESCALATION_TOOL" "$PACKAGER" -y install meld "$ESCALATION_TOOL" "$PACKAGER" -y install meld
;; ;;
*) *)
. ../setup-flatpak.sh checkFlatpak
flatpak install -y flathub org.gnome.meld flatpak install -y flathub org.gnome.meld
;; ;;
esac esac

View File

@ -3,14 +3,9 @@
. ../common-script.sh . ../common-script.sh
installBottles() { installBottles() {
if ! command_exists flatpak; then if ! command_exists com.usebottles.bottles; then
printf "%b\n" "${YELLOW}Installing Bottles...${RC}" printf "%b\n" "${YELLOW}Installing Bottles...${RC}"
case "$PACKAGER" in flatpak install -y flathub com.usebottles.bottles
*)
. ./setup-flatpak.sh
flatpak install -y flathub com.usebottles.bottles
;;
esac
else else
printf "%b\n" "${GREEN}Bottles is already installed.${RC}" printf "%b\n" "${GREEN}Bottles is already installed.${RC}"
fi fi
@ -18,4 +13,5 @@ installBottles() {
checkEnv checkEnv
checkEscalationTool checkEscalationTool
checkFlatpak
installBottles installBottles

View File

@ -2,22 +2,39 @@
. ../../common-script.sh . ../../common-script.sh
installLynx() { installVivaldi() {
if ! command_exists lynx; then if ! command_exists vivaldi; then
printf "%b\n" "${YELLOW}Installing Lynx...${RC}" printf "%b\n" "${YELLOW}Installing Vivaldi...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y curl
"$ESCALATION_TOOL" curl -fsSL https://repo.vivaldi.com/archive/linux_signing_key.pub | gpg --dearmor | sudo dd of=/usr/share/keyrings/vivaldi-browser.gpg
"$ESCALATION_TOOL" echo "deb [signed-by=/usr/share/keyrings/vivaldi-browser.gpg arch=$(dpkg --print-architecture)] https://repo.vivaldi.com/archive/deb/ stable main" | sudo dd of=/etc/apt/sources.list.d/vivaldi-archive.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y vivaldi-stable
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y dnf-plugins-core
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://repo.vivaldi.com/stable/vivaldi-fedora.repo
"$ESCALATION_TOOL" "$PACKAGER" install -y vivaldi-stable
;;
zypper)
"$ESCALATION_TOOL" zypper ar https://repo.vivaldi.com/archive/vivaldi-suse.repo
"$ESCALATION_TOOL" zypper --non-interactive --gpg-auto-import-keys in vivaldi-stable
;;
pacman) pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm lynx "$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm vivaldi
;; ;;
*) *)
"$ESCALATION_TOOL" "$PACKAGER" install -y lynx printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;; ;;
esac esac
else else
printf "%b\n" "${GREEN}Lynx TUI Browser is already installed.${RC}" printf "%b\n" "${GREEN}Vivaldi Browser is already installed.${RC}"
fi fi
} }
checkEnv checkEnv
checkEscalationTool checkEscalationTool
installLynx installVivaldi

View File

@ -3,7 +3,7 @@
. ../../common-script.sh . ../../common-script.sh
installSignal() { installSignal() {
if ! command_exists signal; then if ! command_exists org.signal.Signal && ! command_exists signal; then
printf "%b\n" "${YELLOW}Installing Signal...${RC}" printf "%b\n" "${YELLOW}Installing Signal...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
apt-get|nala) apt-get|nala)
@ -20,8 +20,8 @@ installSignal() {
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm signal-desktop "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm signal-desktop
;; ;;
dnf) dnf)
"$ESCALATION_TOOL" "$PACKAGER" copr enable luminoso/Signal-Desktop checkFlatpak
"$ESCALATION_TOOL" "$PACKAGER" install -y signal-desktop flatpak install -y flathub org.signal.Signal
;; ;;
*) *)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"

View File

@ -3,14 +3,14 @@
. ../../common-script.sh . ../../common-script.sh
installSlack() { installSlack() {
if ! command_exists slack; then if ! command_exists com.slack.Slack && ! command_exists slack; then
printf "%b\n" "${YELLOW}Installing Slack...${RC}" printf "%b\n" "${YELLOW}Installing Slack...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
pacman) pacman)
"$AUR_HELPER" -S --needed --noconfirm slack-desktop "$AUR_HELPER" -S --needed --noconfirm slack-desktop
;; ;;
*) *)
. ../setup-flatpak.sh checkFlatpak
flatpak install -y flathub com.slack.Slack flatpak install -y flathub com.slack.Slack
;; ;;
esac esac

View File

@ -3,14 +3,14 @@
. ../../common-script.sh . ../../common-script.sh
installZoom() { installZoom() {
if ! command_exists zoom; then if ! command_exists us.zoom.Zoom && ! command_exists zoom; then
printf "%b\n" "${YELLOW}Installing Zoom...${RC}" printf "%b\n" "${YELLOW}Installing Zoom...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
pacman) pacman)
"$AUR_HELPER" -S --needed --noconfirm zoom "$AUR_HELPER" -S --needed --noconfirm zoom
;; ;;
*) *)
. ../setup-flatpak.sh checkFlatpak
flatpak install -y flathub us.zoom.Zoom flatpak install -y flathub us.zoom.Zoom
;; ;;
esac esac

View File

@ -26,6 +26,12 @@ install_docker() {
apt-get|nala) apt-get|nala)
curl -fsSL https://get.docker.com | sh 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) zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker
"$ESCALATION_TOOL" systemctl enable docker "$ESCALATION_TOOL" systemctl enable docker
@ -49,6 +55,11 @@ install_docker_compose() {
apt-get|nala) apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y docker-compose-plugin "$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) zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose "$ESCALATION_TOOL" "$PACKAGER" --non-interactive install docker-compose
;; ;;

View File

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

View File

@ -1,16 +1,16 @@
#!/bin/sh -e #!/bin/sh -e
. ../common-script.sh . ../../common-script.sh
installLibreOffice() { installLibreOffice() {
if ! command_exists libreoffice; then if ! command_exists org.libreoffice.LibreOffice && ! command_exists libreoffice; then
printf "%b\n" "${YELLOW}Installing Libre Office...${RC}" printf "%b\n" "${YELLOW}Installing Libre Office...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
apt-get|nala) apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y libreoffice-core "$ESCALATION_TOOL" "$PACKAGER" install -y libreoffice-core
;; ;;
zypper|dnf) zypper|dnf)
. ./setup-flatpak.sh checkFlatpak
flatpak install -y flathub org.libreoffice.LibreOffice flatpak install -y flathub org.libreoffice.LibreOffice
;; ;;
pacman) pacman)

View File

@ -1,9 +1,9 @@
#!/bin/sh -e #!/bin/sh -e
. ../common-script.sh . ../../common-script.sh
installOnlyOffice() { installOnlyOffice() {
if ! command_exists onlyoffice-desktopeditors; then if ! command_exists org.onlyoffice.desktopeditors && ! command_exists onlyoffice-desktopeditors; then
printf "%b\n" "${YELLOW}Installing Only Office..${RC}." printf "%b\n" "${YELLOW}Installing Only Office..${RC}."
case "$PACKAGER" in case "$PACKAGER" in
apt-get|nala) apt-get|nala)
@ -11,7 +11,7 @@ installOnlyOffice() {
"$ESCALATION_TOOL" "$PACKAGER" install -y ./onlyoffice-desktopeditors_amd64.deb "$ESCALATION_TOOL" "$PACKAGER" install -y ./onlyoffice-desktopeditors_amd64.deb
;; ;;
zypper|dnf) zypper|dnf)
. ./setup-flatpak.sh checkFlatpak
flatpak install -y flathub org.onlyoffice.desktopeditors flatpak install -y flathub org.onlyoffice.desktopeditors
;; ;;
pacman) pacman)

View File

@ -1,16 +1,16 @@
#!/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 && ! command_exists wps; then
printf "%b\n" "${YELLOW}Installing WPS Office...${RC}" printf "%b\n" "${YELLOW}Installing WPS Office...${RC}"
case "$PACKAGER" in case "$PACKAGER" in
pacman) pacman)
"$AUR_HELPER" -S --needed --noconfirm wps-office "$AUR_HELPER" -S --needed --noconfirm wps-office
;; ;;
*) *)
. ./setup-flatpak.sh checkFlatpak
flatpak install flathub com.wps.Office flatpak install flathub com.wps.Office
;; ;;
esac esac

View File

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

View File

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

View File

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

View File

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

View File

@ -2,9 +2,7 @@
. ../common-script.sh . ../common-script.sh
# Used to detect the desktop environment, Only used for the If statement in the setup_flatpak function. checkDE() {
# Perhaps this should be moved to common-script.sh later on?
detect_de() {
if [ -n "$XDG_CURRENT_DESKTOP" ]; then if [ -n "$XDG_CURRENT_DESKTOP" ]; then
case "$XDG_CURRENT_DESKTOP" in case "$XDG_CURRENT_DESKTOP" in
*GNOME*) *GNOME*)
@ -17,42 +15,11 @@ detect_de() {
fi fi
} }
# Install Flatpak if not already installed. installExtra() {
setup_flatpak() {
if ! command_exists flatpak; then
printf "%b\n" "${YELLOW}Installing Flatpak...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
;;
esac
printf "%b\n" "Adding Flathub remote..."
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
else
if command_exists flatpak; then
if ! flatpak remotes | grep -q "flathub"; then
printf "%b" "${YELLOW}Detected Flatpak package manager but Flathub remote is not added. Would you like to add it? (y/N): ${RC}"
read -r add_remote
case "$add_remote" in
[Yy]*)
printf "%b\n" "Adding Flathub remote..."
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
;;
esac
else
# Needed mostly for systems without a polkit agent running (Error: updating: Unable to connect to system bus)
printf "%b\n" "${GREEN}Flathub already setup. You can quit.${RC}"
fi
fi
fi
if [ "$PACKAGER" = "apt-get" ] || [ "$PACKAGER" = "nala" ]; then if [ "$PACKAGER" = "apt-get" ] || [ "$PACKAGER" = "nala" ]; then
detect_de checkDE
# Only used for Ubuntu GNOME. Ubuntu GNOME doesnt allow flathub to be added as a remote to their store. # Only used for Ubuntu GNOME. Ubuntu GNOME doesnt allow flathub to be added as a remote to their store.
# So in case the user wants to use a GUI siftware manager they can setup it here # So in case the user wants to use a GUI software manager they can setup it here
if [ "$DE" = "GNOME" ]; then if [ "$DE" = "GNOME" ]; then
printf "%b" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/N): ${RC}" printf "%b" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/N): ${RC}"
read -r install_gnome read -r install_gnome
@ -72,4 +39,5 @@ setup_flatpak() {
checkEnv checkEnv
checkEscalationTool checkEscalationTool
setup_flatpak checkFlatpak
installExtra

View File

@ -54,6 +54,12 @@ description = "GitHub Desktop is a user-friendly application that simplifies the
script = "Developer-tools/githubdesktop-setup.sh" script = "Developer-tools/githubdesktop-setup.sh"
task_list = "I" task_list = "I"
[[data.entries]]
name = "JetBrains Toolbox"
description = "JetBrains Toolbox is a collection of tools and an app that help developers work with JetBrains products."
script = "Developer-tools/jetbrains-toolbox.sh"
task_list = "I"
[[data.entries]] [[data.entries]]
name = "Meld" name = "Meld"
description = "Meld is a visual diff and merge tool that helps compare files, directories, and version-controlled projects." description = "Meld is a visual diff and merge tool that helps compare files, directories, and version-controlled projects."

View File

@ -9,10 +9,48 @@ CYAN='\033[36m'
GREEN='\033[32m' GREEN='\033[32m'
command_exists() { command_exists() {
for cmd in "$@"; do for cmd in "$@"; do
command -v "$cmd" >/dev/null 2>&1 || return 1 export PATH=/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH
done command -v "$cmd" >/dev/null 2>&1 || return 1
return 0 done
return 0
}
checkFlatpak() {
if ! command_exists flatpak; then
printf "%b\n" "${YELLOW}Installing Flatpak...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add flatpak
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
;;
esac
printf "%b\n" "${YELLOW}Adding Flathub remote...${RC}"
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
printf "%b\n" "${YELLOW}Applications installed by Flatpak may not appear on your desktop until the user session is restarted...${RC}"
else
if ! flatpak remotes | grep -q "flathub"; then
printf "%b\n" "${YELLOW}Adding Flathub remote...${RC}"
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
else
printf "%b\n" "${CYAN}Flatpak is installed${RC}"
fi
fi
}
checkArch() {
case "$(uname -m)" in
x86_64 | amd64) ARCH="x86_64" ;;
aarch64 | arm64) ARCH="aarch64" ;;
*) printf "%b\n" "${RED}Unsupported architecture: $(uname -m)${RC}" && exit 1 ;;
esac
printf "%b\n" "${CYAN}System architecture: ${ARCH}${RC}"
} }
checkAURHelper() { checkAURHelper() {
@ -128,6 +166,7 @@ checkDistro() {
} }
checkEnv() { checkEnv() {
checkArch
checkEscalationTool checkEscalationTool
checkCommandRequirements "curl groups $ESCALATION_TOOL" checkCommandRequirements "curl groups $ESCALATION_TOOL"
checkPackageManager 'nala apt-get dnf pacman zypper' checkPackageManager 'nala apt-get dnf pacman zypper'

View File

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

View File

@ -130,7 +130,7 @@ echo -ne "
██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
------------------------------------------------------------------------ ------------------------------------------------------------------------
Please select presetup settings for your system Please select presetup settings for your system
------------------------------------------------------------------------ ------------------------------------------------------------------------
" "
} }
@ -146,7 +146,7 @@ filesystem () {
case $? in case $? in
0) export FS=btrfs;; 0) export FS=btrfs;;
1) export FS=ext4;; 1) export FS=ext4;;
2) 2)
set_password "LUKS_PASSWORD" set_password "LUKS_PASSWORD"
export FS=luks export FS=luks
;; ;;
@ -155,14 +155,14 @@ filesystem () {
esac esac
} }
# @description Detects and sets timezone. # @description Detects and sets timezone.
timezone () { timezone () {
# Added this from arch wiki https://wiki.archlinux.org/title/System_time # Added this from arch wiki https://wiki.archlinux.org/title/System_time
time_zone="$(curl --fail https://ipapi.co/timezone)" time_zone="$(curl --fail https://ipapi.co/timezone)"
echo -ne " echo -ne "
System detected your timezone to be '$time_zone' \n" System detected your timezone to be '$time_zone' \n"
echo -ne "Is this correct? echo -ne "Is this correct?
" "
options=("Yes" "No") options=("Yes" "No")
select_option "${options[@]}" select_option "${options[@]}"
@ -171,14 +171,14 @@ timezone () {
echo "${time_zone} set as timezone" echo "${time_zone} set as timezone"
export TIMEZONE=$time_zone;; export TIMEZONE=$time_zone;;
n|N|no|NO|No) n|N|no|NO|No)
echo "Please enter your desired timezone e.g. Europe/London :" echo "Please enter your desired timezone e.g. Europe/London :"
read -r new_timezone read -r new_timezone
echo "${new_timezone} set as timezone" echo "${new_timezone} set as timezone"
export TIMEZONE=$new_timezone;; export TIMEZONE=$new_timezone;;
*) echo "Wrong option. Try again";timezone;; *) echo "Wrong option. Try again";timezone;;
esac esac
} }
# @description Set user's keyboard mapping. # @description Set user's keyboard mapping.
keymap () { keymap () {
echo -ne " echo -ne "
Please select key board layout from this list" Please select key board layout from this list"
@ -236,18 +236,18 @@ echo -ne "
drivessd drivessd
} }
# @description Gather username and password to be used for installation. # @description Gather username and password to be used for installation.
userinfo () { userinfo () {
# Loop through user input until the user gives a valid username # Loop through user input until the user gives a valid username
while true while true
do do
read -r -p "Please enter username: " username read -r -p "Please enter username: " username
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]] if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
then then
break break
fi fi
echo "Incorrect username." echo "Incorrect username."
done done
export USERNAME=$username export USERNAME=$username
while true while true
@ -264,22 +264,22 @@ userinfo () {
done done
export PASSWORD=$PASSWORD1 export PASSWORD=$PASSWORD1
# Loop through user input until the user gives a valid hostname, but allow the user to force save # Loop through user input until the user gives a valid hostname, but allow the user to force save
while true while true
do do
read -r -p "Please name your machine: " name_of_machine read -r -p "Please name your machine: " name_of_machine
# hostname regex (!!couldn't find spec for computer name!!) # hostname regex (!!couldn't find spec for computer name!!)
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]] if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
then then
break break
fi fi
# if validation fails allow the user to force saving of the hostname # if validation fails allow the user to force saving of the hostname
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
if [[ "${force,,}" = "y" ]] if [[ "${force,,}" = "y" ]]
then then
break break
fi fi
done done
export NAME_OF_MACHINE=$name_of_machine export NAME_OF_MACHINE=$name_of_machine
} }
@ -351,7 +351,7 @@ echo -ne "
Creating Filesystems Creating Filesystems
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
# @description Creates the btrfs subvolumes. # @description Creates the btrfs subvolumes.
createsubvolumes () { createsubvolumes () {
btrfs subvolume create /mnt/@ btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home btrfs subvolume create /mnt/@home
@ -362,11 +362,11 @@ mountallsubvol () {
mount -o "${MOUNT_OPTIONS}",subvol=@home "${partition3}" /mnt/home mount -o "${MOUNT_OPTIONS}",subvol=@home "${partition3}" /mnt/home
} }
# @description BTRFS subvolulme creation and mounting. # @description BTRFS subvolulme creation and mounting.
subvolumesetup () { subvolumesetup () {
# create nonroot subvolumes # create nonroot subvolumes
createsubvolumes createsubvolumes
# unmount root to remount with subvolume # unmount root to remount with subvolume
umount /mnt umount /mnt
# mount @ subvolume # mount @ subvolume
mount -o "${MOUNT_OPTIONS}",subvol=@ "${partition3}" /mnt mount -o "${MOUNT_OPTIONS}",subvol=@ "${partition3}" /mnt
@ -386,33 +386,36 @@ fi
if [[ "${FS}" == "btrfs" ]]; then if [[ "${FS}" == "btrfs" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}" mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
mkfs.btrfs -L ROOT "${partition3}" -f mkfs.btrfs -f "${partition3}"
mount -t btrfs "${partition3}" /mnt mount -t btrfs "${partition3}" /mnt
subvolumesetup subvolumesetup
elif [[ "${FS}" == "ext4" ]]; then elif [[ "${FS}" == "ext4" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}" mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
mkfs.ext4 -L ROOT "${partition3}" mkfs.ext4 "${partition3}"
mount -t ext4 "${partition3}" /mnt mount -t ext4 "${partition3}" /mnt
elif [[ "${FS}" == "luks" ]]; then elif [[ "${FS}" == "luks" ]]; then
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}" mkfs.vfat -F32 "${partition2}"
# enter luks password to cryptsetup and format root partition # enter luks password to cryptsetup and format root partition
echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat "${partition3}" - echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat "${partition3}" -
# open luks container and ROOT will be place holder # open luks container and ROOT will be place holder
echo -n "${LUKS_PASSWORD}" | cryptsetup open "${partition3}" ROOT - echo -n "${LUKS_PASSWORD}" | cryptsetup open "${partition3}" ROOT -
# now format that container # now format that container
mkfs.btrfs -L ROOT "${partition3}" mkfs.btrfs "${partition3}"
# create subvolumes for btrfs # create subvolumes for btrfs
mount -t btrfs "${partition3}" /mnt mount -t btrfs "${partition3}" /mnt
subvolumesetup subvolumesetup
ENCRYPTED_PARTITION_UUID=$(blkid -s UUID -o value "${partition3}")
fi fi
BOOT_UUID=$(blkid -s UUID -o value "${partition2}")
sync sync
if ! mountpoint -q /mnt; then if ! mountpoint -q /mnt; then
echo "ERROR! Failed to mount ${partition3} to /mnt after multiple attempts." echo "ERROR! Failed to mount ${partition3} to /mnt after multiple attempts."
exit 1 exit 1
fi fi
mkdir -p /mnt/boot/efi mkdir -p /mnt/boot/efi
mount -t vfat -L EFIBOOT /mnt/boot/ mount -t vfat -U "${BOOT_UUID}" /mnt/boot/
if ! grep -qs '/mnt' /proc/mounts; then if ! grep -qs '/mnt' /proc/mounts; then
echo "Drive is not mounted can not continue" echo "Drive is not mounted can not continue"
@ -435,8 +438,8 @@ fi
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
genfstab -L /mnt >> /mnt/etc/fstab genfstab -U /mnt >> /mnt/etc/fstab
echo " echo "
Generated /etc/fstab: Generated /etc/fstab:
" "
cat /mnt/etc/fstab cat /mnt/etc/fstab
@ -475,14 +478,14 @@ arch-chroot /mnt /bin/bash -c "KEYMAP='${KEYMAP}' /bin/bash" <<EOF
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Network Setup Network Setup
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
pacman -S --noconfirm --needed networkmanager dhclient pacman -S --noconfirm --needed networkmanager dhclient
systemctl enable --now NetworkManager systemctl enable --now NetworkManager
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Setting up mirrors for optimal download Setting up mirrors for optimal download
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
pacman -S --noconfirm --needed pacman-contrib curl pacman -S --noconfirm --needed pacman-contrib curl
@ -504,7 +507,7 @@ sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg
fi fi
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
Setup Language to US and set locale Setup Language to US and set locale
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
@ -526,6 +529,9 @@ sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: A
#Add parallel downloading #Add parallel downloading
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
#Set colors and enable the easter egg
sed -i 's/^#Color/Color\nILoveCandy/' /etc/pacman.conf
#Enable multilib #Enable multilib
sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf
pacman -Sy --noconfirm --needed pacman -Sy --noconfirm --needed
@ -572,7 +578,7 @@ echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
" "
groupadd libvirt groupadd libvirt
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash" echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash"
echo "$USERNAME:$PASSWORD" | chpasswd echo "$USERNAME:$PASSWORD" | chpasswd
echo "$USERNAME password set" echo "$USERNAME password set"

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

@ -7,10 +7,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

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" 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"

View File

@ -8,7 +8,7 @@ printf "%b\n" "${YELLOW}Ensuring OpenSSL is installed...${RC}"
if ! command_exists openssl; then if ! command_exists openssl; then
case "$PACKAGER" in case "$PACKAGER" in
pacman) pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Syu --noconfirm openssl "$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm --needed openssl
;; ;;
apt-get|nala) apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y openssl "$ESCALATION_TOOL" "$PACKAGER" install -y openssl

12
core/tabs/utils/monitor-control/set_brightness.sh Normal file → Executable file
View 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

View File

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

View File

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

View File

@ -14,21 +14,21 @@ default = ["tips"]
tips = ["rand"] tips = ["rand"]
[dependencies] [dependencies]
clap = { version = "4.5.19", features = ["derive"] } clap = { version = "4.5.20", features = ["derive"] }
crossterm = "0.28.1" crossterm = "0.28.1"
ego-tree = { workspace = true } ego-tree = { workspace = true }
oneshot = "0.1.8" oneshot = "0.1.8"
portable-pty = "0.8.1" portable-pty = "0.8.1"
ratatui = "0.28.1" ratatui = "0.29.0"
tui-term = "0.1.12" tui-term = "0.2.0"
temp-dir = "0.1.14" temp-dir = "0.1.14"
unicode-width = "0.2.0" unicode-width = "0.2.0"
rand = { version = "0.8.5", optional = true } rand = { version = "0.8.5", optional = true }
linutil_core = { path = "../core", version = "24.9.28" } linutil_core = { path = "../core", version = "24.9.28" }
tree-sitter-highlight = "0.24.2" tree-sitter-highlight = "0.24.3"
tree-sitter-bash = "0.23.1" tree-sitter-bash = "0.23.1"
anstyle = "1.0.8" anstyle = "1.0.8"
ansi-to-tui = "6.0.0" ansi-to-tui = "7.0.0"
zips = "0.1.7" zips = "0.1.7"
[[bin]] [[bin]]

View File

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

View File

@ -4,7 +4,7 @@ use ego_tree::NodeId;
use linutil_core::Tab; use linutil_core::Tab;
use ratatui::{ use ratatui::{
layout::{Position, Rect}, layout::{Position, Rect},
style::Style, style::{Color, Style},
text::Span, text::Span,
widgets::{Block, Borders, Paragraph}, widgets::{Block, Borders, Paragraph},
Frame, Frame,
@ -22,6 +22,7 @@ pub struct Filter {
in_search_mode: bool, in_search_mode: bool,
input_position: usize, input_position: usize,
items: Vec<ListEntry>, items: Vec<ListEntry>,
completion_preview: Option<String>,
} }
impl Filter { impl Filter {
@ -31,17 +32,23 @@ impl Filter {
in_search_mode: false, in_search_mode: false,
input_position: 0, input_position: 0,
items: vec![], items: vec![],
completion_preview: None,
} }
} }
pub fn item_list(&self) -> &[ListEntry] { pub fn item_list(&self) -> &[ListEntry] {
&self.items &self.items
} }
pub fn activate_search(&mut self) { pub fn activate_search(&mut self) {
self.in_search_mode = true; self.in_search_mode = true;
} }
pub fn deactivate_search(&mut self) { pub fn deactivate_search(&mut self) {
self.in_search_mode = false; self.in_search_mode = false;
self.completion_preview = None;
} }
pub fn update_items(&mut self, tabs: &[Tab], current_tab: usize, node: NodeId) { pub fn update_items(&mut self, tabs: &[Tab], current_tab: usize, node: NodeId) {
if self.search_input.is_empty() { if self.search_input.is_empty() {
let curr = tabs[current_tab].tree.get(node).unwrap(); let curr = tabs[current_tab].tree.get(node).unwrap();
@ -78,13 +85,34 @@ impl Filter {
} }
self.items.sort_by(|a, b| a.node.name.cmp(&b.node.name)); self.items.sort_by(|a, b| a.node.name.cmp(&b.node.name));
} }
self.update_completion_preview();
} }
fn update_completion_preview(&mut self) {
if self.search_input.is_empty() {
self.completion_preview = None;
return;
}
let input = self.search_input.iter().collect::<String>().to_lowercase();
self.completion_preview = self.items.iter().find_map(|item| {
let item_name_lower = item.node.name.to_lowercase();
if item_name_lower.starts_with(&input) {
Some(item_name_lower[input.len()..].to_string())
} else {
None
}
});
}
pub fn draw_searchbar(&self, frame: &mut Frame, area: Rect, theme: &Theme) { pub fn draw_searchbar(&self, frame: &mut Frame, area: Rect, theme: &Theme) {
//Set the search bar text (If empty use the placeholder) //Set the search bar text (If empty use the placeholder)
let display_text = if !self.in_search_mode && self.search_input.is_empty() { let display_text = if !self.in_search_mode && self.search_input.is_empty() {
Span::raw("Press / to search") Span::raw("Press / to search")
} else { } else {
Span::raw(self.search_input.iter().collect::<String>()) let input_text = self.search_input.iter().collect::<String>();
Span::styled(input_text, Style::default().fg(theme.focused_color()))
}; };
let search_color = if self.in_search_mode { let search_color = if self.in_search_mode {
@ -95,7 +123,7 @@ impl Filter {
//Create the search bar widget //Create the search bar widget
let search_bar = Paragraph::new(display_text) 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)); .style(Style::default().fg(search_color));
//Render the search bar (First chunk of the screen) //Render the search bar (First chunk of the screen)
@ -110,11 +138,22 @@ impl Filter {
let x = area.x + cursor_position as u16 + 1; let x = area.x + cursor_position as u16 + 1;
let y = area.y + 1; let y = area.y + 1;
frame.set_cursor_position(Position::new(x, y)); frame.set_cursor_position(Position::new(x, y));
if let Some(preview) = &self.completion_preview {
let preview_span = Span::styled(preview, Style::default().fg(Color::DarkGray));
let preview_paragraph = Paragraph::new(preview_span).style(Style::default());
let preview_area = Rect::new(
x,
y,
(preview.len() as u16).min(area.width - cursor_position as u16 - 1),
1,
);
frame.render_widget(preview_paragraph, preview_area);
}
} }
} }
// Handles key events. Returns true if search must be exited // Handles key events. Returns true if search must be exited
pub fn handle_key(&mut self, event: &KeyEvent) -> SearchAction { pub fn handle_key(&mut self, event: &KeyEvent) -> SearchAction {
//Insert user input into the search bar
match event.code { match event.code {
KeyCode::Char('c') if event.modifiers.contains(KeyModifiers::CONTROL) => { KeyCode::Char('c') if event.modifiers.contains(KeyModifiers::CONTROL) => {
return self.exit_search() return self.exit_search()
@ -124,10 +163,17 @@ impl Filter {
KeyCode::Delete => self.remove_next(), KeyCode::Delete => self.remove_next(),
KeyCode::Left => return self.cursor_left(), KeyCode::Left => return self.cursor_left(),
KeyCode::Right => return self.cursor_right(), KeyCode::Right => return self.cursor_right(),
KeyCode::Tab => return self.complete_search(),
KeyCode::Esc => {
self.input_position = 0;
self.search_input.clear();
self.completion_preview = None;
return SearchAction::Exit;
}
KeyCode::Enter => return SearchAction::Exit, KeyCode::Enter => return SearchAction::Exit,
KeyCode::Esc => return self.exit_search(),
_ => return SearchAction::None, _ => return SearchAction::None,
}; };
self.update_completion_preview();
SearchAction::Update SearchAction::Update
} }
@ -141,16 +187,19 @@ impl Filter {
self.input_position = self.input_position.saturating_sub(1); self.input_position = self.input_position.saturating_sub(1);
SearchAction::None SearchAction::None
} }
fn cursor_right(&mut self) -> SearchAction { fn cursor_right(&mut self) -> SearchAction {
if self.input_position < self.search_input.len() { if self.input_position < self.search_input.len() {
self.input_position += 1; self.input_position += 1;
} }
SearchAction::None SearchAction::None
} }
fn insert_char(&mut self, input: char) { fn insert_char(&mut self, input: char) {
self.search_input.insert(self.input_position, input); self.search_input.insert(self.input_position, input);
self.cursor_right(); self.cursor_right();
} }
fn remove_previous(&mut self) { fn remove_previous(&mut self) {
let current = self.input_position; let current = self.input_position;
if current > 0 { if current > 0 {
@ -158,10 +207,27 @@ impl Filter {
self.cursor_left(); self.cursor_left();
} }
} }
fn remove_next(&mut self) { fn remove_next(&mut self) {
let current = self.input_position; let current = self.input_position;
if current < self.search_input.len() { if current < self.search_input.len() {
self.search_input.remove(current); self.search_input.remove(current);
} }
} }
fn complete_search(&mut self) -> SearchAction {
if let Some(completion) = self.completion_preview.take() {
self.search_input.extend(completion.chars());
self.input_position = self.search_input.len();
self.update_completion_preview();
SearchAction::Update
} else {
SearchAction::None
}
}
pub fn clear_search(&mut self) {
self.search_input.clear();
self.input_position = 0;
}
} }

View File

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

View File

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

View File

@ -24,7 +24,7 @@ use temp_dir::TempDir;
const MIN_WIDTH: u16 = 100; const MIN_WIDTH: u16 = 100;
const MIN_HEIGHT: u16 = 25; const MIN_HEIGHT: u16 = 25;
const TITLE: &str = concat!("Linux Toolbox - ", env!("CARGO_PKG_VERSION")); 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)
@ -61,7 +61,7 @@ pub struct AppState {
selected_commands: Vec<Rc<ListNode>>, selected_commands: Vec<Rc<ListNode>>,
drawable: bool, drawable: bool,
#[cfg(feature = "tips")] #[cfg(feature = "tips")]
tip: &'static str, tip: String,
} }
pub enum Focus { pub enum Focus {
@ -375,17 +375,17 @@ impl AppState {
}; };
let title = if self.multi_select { let title = if self.multi_select {
&format!("{} [Multi-Select]", TITLE) &format!("{}[Multi-Select] ", TITLE)
} else { } else {
TITLE TITLE
}; };
#[cfg(feature = "tips")] #[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"))] #[cfg(not(feature = "tips"))]
let bottom_title = ""; 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 // Create the list widget with items
let list = List::new(items) let list = List::new(items)
@ -420,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;
} }
@ -704,8 +708,10 @@ 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);
}
} }
} }
@ -783,6 +789,7 @@ impl AppState {
0usize, 0usize,
)]; )];
self.selection.select(Some(0)); self.selection.select(Some(0));
self.filter.clear_search();
self.update_items(); self.update_items();
} }
@ -817,13 +824,13 @@ impl AppState {
const TIPS: &str = include_str!("../cool_tips.txt"); const TIPS: &str = include_str!("../cool_tips.txt");
#[cfg(feature = "tips")] #[cfg(feature = "tips")]
fn get_random_tip() -> &'static str { fn get_random_tip() -> String {
let tips: Vec<&str> = TIPS.lines().collect(); let tips: Vec<&str> = TIPS.lines().collect();
if tips.is_empty() { if tips.is_empty() {
return ""; return "".to_string();
} }
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let random_index = rng.gen_range(0..tips.len()); let random_index = rng.gen_range(0..tips.len());
tips[random_index] format!(" {} ", tips[random_index])
} }