mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-21 21:09:42 +00:00
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
commit
cdd7834b9d
21
.github/workflows/linutil.yml
vendored
21
.github/workflows/linutil.yml
vendored
|
@ -89,22 +89,23 @@ jobs:
|
||||||
version: ${{ env.version }}
|
version: ${{ env.version }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Install vhs
|
- name: Setup Preview
|
||||||
run: |
|
run: |
|
||||||
wget 'https://github.com/charmbracelet/vhs/releases/download/v0.8.0/vhs_0.8.0_amd64.deb'
|
echo "$(pwd)/build" >> $GITHUB_PATH
|
||||||
sudo apt install -y ffmpeg
|
|
||||||
sudo snap install ttyd --classic
|
- name: Generate preview
|
||||||
sudo dpkg -i 'vhs_0.8.0_amd64.deb'
|
uses: charmbracelet/vhs-action@v2.1.0
|
||||||
|
with:
|
||||||
|
path: "docs/assets/preview.tape"
|
||||||
|
|
||||||
- name: Build the preview
|
- name: Move preview
|
||||||
run: |
|
run: |
|
||||||
export PATH="$(pwd)/build:$PATH"
|
mv preview.gif docs/assets/preview.gif
|
||||||
vhs docs/assets/preview.tape -o docs/assets/preview.gif
|
|
||||||
|
|
||||||
- name: Upload the preview
|
- name: Upload preview
|
||||||
uses: stefanzweifel/git-auto-commit-action@v5
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
with:
|
with:
|
||||||
commit_message: Preview for ${{ env.version }}
|
commit_message: Preview for ${{ env.version }}
|
||||||
file_pattern: "docs/assets/preview.gif"
|
file_pattern: "docs/assets/preview.gif"
|
||||||
add_options: "--force"
|
add_options: "--force"
|
||||||
if: success()
|
if: success()
|
43
.github/workflows/shellcheck.yml
vendored
43
.github/workflows/shellcheck.yml
vendored
|
@ -14,17 +14,42 @@ jobs:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- run: git fetch origin ${{ github.base_ref }}
|
- run: git fetch origin ${{ github.base_ref }}
|
||||||
|
|
||||||
- name: Download and set up shellcheck
|
- name: Download, setup, and run ShellCheck
|
||||||
|
shell: bash {0}
|
||||||
run : |
|
run : |
|
||||||
wget https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz
|
SC_URL="https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz"
|
||||||
tar -xf shellcheck-v0.10.0.linux.x86_64.tar.xz
|
curl -fsSL "$SC_URL" | tar -Jx
|
||||||
cd shellcheck-v0.10.0
|
chmod +x "./shellcheck-v0.10.0/shellcheck"
|
||||||
chmod +x shellcheck
|
|
||||||
|
|
||||||
- name: Run shellcheck
|
error=0
|
||||||
run: |
|
files_to_check=$(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs)
|
||||||
for file in $(git diff --name-only origin/${{ github.base_ref }} HEAD core/tabs); do
|
|
||||||
|
for file in $files_to_check; do
|
||||||
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then
|
if [[ "$file" == *.sh ]] && [[ -f "$file" ]]; then
|
||||||
./shellcheck-v0.10.0/shellcheck -S error "$file"
|
sc_output=$(./shellcheck-v0.10.0/shellcheck -fgcc -Serror "$file")
|
||||||
|
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')
|
||||||
|
|
||||||
|
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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
exit $error
|
||||||
|
|
15
.github/workflows/typos.yml
vendored
Normal file
15
.github/workflows/typos.yml
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
name: Check for typos
|
||||||
|
|
||||||
|
on:
|
||||||
|
[push, pull_request, workflow_dispatch]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-typos:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: git fetch origin ${{ github.base_ref }}
|
||||||
|
|
||||||
|
- name: Run spellcheck
|
||||||
|
uses: crate-ci/typos@v1.25.0
|
36
Cargo.lock
generated
36
Cargo.lock
generated
|
@ -121,9 +121,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.18"
|
version = "1.1.28"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476"
|
checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
@ -150,9 +150,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.18"
|
version = "4.5.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3"
|
checksum = "7be5744db7978a28d9df86a214130d106a89ce49644cbc4e3f0c22c3fba30615"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
@ -160,9 +160,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.18"
|
version = "4.5.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b"
|
checksum = "a5fbc17d3ef8278f55b282b2a2e75ae6f6c7d4bb70ed3d0382375104bfafdb4b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"clap_lex",
|
"clap_lex",
|
||||||
|
@ -914,6 +914,12 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "streaming-iterator"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b2231b7c3057d5e4ad0156fb3dc807d900806020c5ffa3ee6ff2c8c76fb8520"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strum"
|
name = "strum"
|
||||||
version = "0.26.3"
|
version = "0.26.3"
|
||||||
|
@ -964,18 +970,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.63"
|
version = "1.0.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.63"
|
version = "1.0.64"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1018,13 +1024,14 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tree-sitter"
|
name = "tree-sitter"
|
||||||
version = "0.23.0"
|
version = "0.24.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "20f4cd3642c47a85052a887d86704f4eac272969f61b686bdd3f772122aabaff"
|
checksum = "23b84f60031bf8245b563a80c92c1034e557a914f7958f474bc0afa2eed78b98"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"regex",
|
"regex",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
|
"streaming-iterator",
|
||||||
"tree-sitter-language",
|
"tree-sitter-language",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1040,12 +1047,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tree-sitter-highlight"
|
name = "tree-sitter-highlight"
|
||||||
version = "0.23.0"
|
version = "0.24.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "395d7a477a4504fd7d5e4d003e0dd41bd5b9c4985d53592a943a8354ec452dae"
|
checksum = "5c727fb31f816c09fc54dc0e971d101318926866f7261b2acb820e84a61bf52d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"regex",
|
"regex",
|
||||||
|
"streaming-iterator",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tree-sitter",
|
"tree-sitter",
|
||||||
]
|
]
|
||||||
|
|
|
@ -49,7 +49,7 @@ makepkg -si
|
||||||
|
|
||||||
Replace `<package>` with your preferred package.
|
Replace `<package>` with your preferred package.
|
||||||
|
|
||||||
If you use [yay](https://github.com/Jguer/yay), [paru](https://github.com/Morganamilo/paru) or any other [AUR Helper](https://wiki.archlinux.org/title/AUR_helpers), it's even simplier:
|
If you use [yay](https://github.com/Jguer/yay), [paru](https://github.com/Morganamilo/paru) or any other [AUR Helper](https://wiki.archlinux.org/title/AUR_helpers), it's even simpler:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
paru -S linutil
|
paru -S linutil
|
||||||
|
|
7
_typos.toml
Normal file
7
_typos.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[files]
|
||||||
|
extend-exclude = ["tui/cool_tips.txt"]
|
||||||
|
|
||||||
|
[default]
|
||||||
|
extend-ignore-identifiers-re = [
|
||||||
|
"ratatui",
|
||||||
|
]
|
|
@ -3,37 +3,37 @@
|
||||||
. ../../common-script.sh
|
. ../../common-script.sh
|
||||||
|
|
||||||
installSublime() {
|
installSublime() {
|
||||||
if ! command_exists sublime; then
|
if ! command_exists sublime; then
|
||||||
printf "%b\n" "${YELLOW}Installing Sublime...${RC}"
|
printf "%b\n" "${YELLOW}Installing Sublime...${RC}"
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add -
|
curl -fsSL https://download.sublimetext.com/sublimehq-pub.gpg | "$ESCALATION_TOOL" apt-key add -
|
||||||
echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list
|
echo "deb https://download.sublimetext.com/ apt/stable/" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/sublime-text.list
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
|
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
|
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo
|
"$ESCALATION_TOOL" "$PACKAGER" addrepo -g -f https://download.sublimetext.com/rpm/dev/x86_64/sublime-text.repo
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" refresh
|
"$ESCALATION_TOOL" "$PACKAGER" refresh
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text
|
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install sublime-text
|
||||||
;;
|
;;
|
||||||
pacman)
|
pacman)
|
||||||
"$AUR_HELPER" -S --needed --noconfirm sublime-text-4
|
"$AUR_HELPER" -S --needed --noconfirm sublime-text-4
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
|
"$ESCALATION_TOOL" rpm -v --import https://download.sublimetext.com/sublimehq-rpm-pub.gpg
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
|
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://download.sublimetext.com/rpm/stable/x86_64/sublime-text.repo
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
|
"$ESCALATION_TOOL" "$PACKAGER" install -y sublime-text
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
printf "%b\n" "${GREEN}Sublime is already installed.${RC}"
|
printf "%b\n" "${GREEN}Sublime is already installed.${RC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,12 @@
|
||||||
|
|
||||||
themeinstall(){
|
themeinstall(){
|
||||||
mkdir -p "$HOME/.local/share"
|
mkdir -p "$HOME/.local/share"
|
||||||
cd "$HOME/.local/share" && git clone "https://github.com/ChrisTitusTech/Top-5-Bootloader-Themes"
|
cd "$HOME/.local/share"
|
||||||
cd "$HOME/.local/share/Top-5-Bootloader-Themes"
|
if [ -d 'Top-5-Bootloader-Themes' ]; then
|
||||||
|
rm -rf 'Top-5-Bootloader-Themes'
|
||||||
|
fi
|
||||||
|
git clone "https://github.com/ChrisTitusTech/Top-5-Bootloader-Themes"
|
||||||
|
cd "Top-5-Bootloader-Themes"
|
||||||
"$ESCALATION_TOOL" ./install.sh
|
"$ESCALATION_TOOL" ./install.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ configureUFW() {
|
||||||
printf "%b\n" "${YELLOW}Allowing port 80/tcp (UFW)${RC}"
|
printf "%b\n" "${YELLOW}Allowing port 80/tcp (UFW)${RC}"
|
||||||
"$ESCALATION_TOOL" ufw allow 80/tcp
|
"$ESCALATION_TOOL" ufw allow 80/tcp
|
||||||
|
|
||||||
printf "%b\n" "${YELLO}Allowing port 443/tcp (UFW)${RC}"
|
printf "%b\n" "${YELLOW}Allowing port 443/tcp (UFW)${RC}"
|
||||||
"$ESCALATION_TOOL" ufw allow 443/tcp
|
"$ESCALATION_TOOL" ufw allow 443/tcp
|
||||||
|
|
||||||
printf "%b\n" "${YELLOW}Denying Incoming Packets by Default(UFW)${RC}"
|
printf "%b\n" "${YELLOW}Denying Incoming Packets by Default(UFW)${RC}"
|
||||||
|
|
|
@ -216,7 +216,7 @@ echo -ne "
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK
|
THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK
|
||||||
Please make sure you know what you are doing because
|
Please make sure you know what you are doing because
|
||||||
after formating your disk there is no way to get data back
|
after formatting your disk there is no way to get data back
|
||||||
*****BACKUP YOUR DATA BEFORE CONTINUING*****
|
*****BACKUP YOUR DATA BEFORE CONTINUING*****
|
||||||
***I AM NOT RESPONSIBLE FOR ANY DATA LOSS***
|
***I AM NOT RESPONSIBLE FOR ANY DATA LOSS***
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
@ -328,7 +328,7 @@ echo -ne "
|
||||||
pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc
|
pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc
|
||||||
echo -ne "
|
echo -ne "
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Formating Disk
|
Formatting Disk
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
umount -A --recursive /mnt # make sure everything is unmounted before we start
|
umount -A --recursive /mnt # make sure everything is unmounted before we start
|
||||||
|
@ -466,7 +466,7 @@ if [[ $TOTAL_MEM -lt 8000000 ]]; then
|
||||||
mkswap /mnt/opt/swap/swapfile
|
mkswap /mnt/opt/swap/swapfile
|
||||||
swapon /mnt/opt/swap/swapfile
|
swapon /mnt/opt/swap/swapfile
|
||||||
# The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself.
|
# The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself.
|
||||||
echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation.
|
echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gpu_type=$(lspci | grep -E "VGA|3D|Display")
|
gpu_type=$(lspci | grep -E "VGA|3D|Display")
|
||||||
|
@ -493,8 +493,8 @@ nc=$(grep -c ^processor /proc/cpuinfo)
|
||||||
echo -ne "
|
echo -ne "
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
You have " $nc" cores. And
|
You have " $nc" cores. And
|
||||||
changing the makeflags for " $nc" cores. Aswell as
|
changing the makeflags for " $nc" cores. Aswell as
|
||||||
changing the compression settings.
|
changing the compression settings.
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
|
TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
|
||||||
|
@ -670,4 +670,4 @@ sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: A
|
||||||
# Add sudo rights
|
# Add sudo rights
|
||||||
sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
|
sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers
|
||||||
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
|
sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -15,30 +15,30 @@ installDepend() {
|
||||||
else
|
else
|
||||||
printf "%b\n" "${GREEN}Multilib is already enabled.${RC}"
|
printf "%b\n" "${GREEN}Multilib is already enabled.${RC}"
|
||||||
fi
|
fi
|
||||||
"$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES"
|
"$AUR_HELPER" -S --needed --noconfirm $DEPENDENCIES
|
||||||
;;
|
;;
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
COMPILEDEPS='build-essential'
|
COMPILEDEPS='build-essential'
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" dpkg --add-architecture i386
|
"$ESCALATION_TOOL" dpkg --add-architecture i386
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
COMPILEDEPS='@development-tools'
|
COMPILEDEPS='@development-tools'
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools
|
"$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
|
"$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
COMPILEDEPS='patterns-devel-base-devel_basis'
|
COMPILEDEPS='patterns-devel-base-devel_basis'
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" refresh
|
"$ESCALATION_TOOL" "$PACKAGER" refresh
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install "$DEPENDENCIES" "$COMPILEDEPS"
|
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install $DEPENDENCIES $COMPILEDEPS
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
|
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ configureDNF() {
|
||||||
echo "fastestmirror=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null
|
echo "fastestmirror=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null
|
||||||
echo "defaultyes=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null
|
echo "defaultyes=True" | "$ESCALATION_TOOL" tee -a /etc/dnf/dnf.conf > /dev/null
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core
|
"$ESCALATION_TOOL" "$PACKAGER" -y install dnf-plugins-core
|
||||||
printf "%b\n" "${GREEN}DNF Configured Succesfully...${RC}"
|
printf "%b\n" "${GREEN}DNF Configured Successfully.${RC}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}"
|
printf "%b\n" "${RED}Unsupported distribution: $DTYPE${RC}"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
. ../../common-script.sh
|
. ../../common-script.sh
|
||||||
# This script allows user to download proprietary drivers for nvidia in fedora
|
# This script allows user to download proprietary drivers for nvidia in fedora
|
||||||
|
|
||||||
# It also disables noveau nvidia drivers
|
# It also disables nouveau nvidia drivers
|
||||||
|
|
||||||
# Installation guide link: https://rpmfusion.org/Howto/NVIDIA
|
# Installation guide link: https://rpmfusion.org/Howto/NVIDIA
|
||||||
|
|
||||||
|
@ -91,4 +91,4 @@ printf "%b\n" "${YELLOW}Warning! This script will enable Nvidia non-free reposit
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
checkEscalationTool
|
checkEscalationTool
|
||||||
userConfirmation
|
userConfirmation
|
||||||
|
|
|
@ -23,7 +23,7 @@ installDepend() {
|
||||||
ncurses lib32-ncurses vulkan-icd-loader lib32-vulkan-icd-loader ocl-icd lib32-ocl-icd libva lib32-libva \
|
ncurses lib32-ncurses vulkan-icd-loader lib32-vulkan-icd-loader ocl-icd lib32-ocl-icd libva lib32-libva \
|
||||||
gst-plugins-base-libs lib32-gst-plugins-base-libs sdl2"
|
gst-plugins-base-libs lib32-gst-plugins-base-libs sdl2"
|
||||||
|
|
||||||
$AUR_HELPER -S --needed --noconfirm "$DEPENDENCIES" "$DISTRO_DEPS"
|
$AUR_HELPER -S --needed --noconfirm $DEPENDENCIES $DISTRO_DEPS
|
||||||
;;
|
;;
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
DISTRO_DEPS="libasound2 libsdl2 wine64 wine32"
|
DISTRO_DEPS="libasound2 libsdl2 wine64 wine32"
|
||||||
|
@ -33,24 +33,24 @@ installDepend() {
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common
|
"$ESCALATION_TOOL" "$PACKAGER" install -y software-properties-common
|
||||||
"$ESCALATION_TOOL" apt-add-repository contrib -y
|
"$ESCALATION_TOOL" apt-add-repository contrib -y
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" update
|
"$ESCALATION_TOOL" "$PACKAGER" update
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$DISTRO_DEPS"
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS
|
||||||
;;
|
;;
|
||||||
dnf)
|
dnf)
|
||||||
if [ "$(rpm -E %fedora)" -le 41 ]; then
|
if [ "$(rpm -E %fedora)" -le 41 ]; then
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y
|
"$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
|
||||||
else
|
else
|
||||||
printf "%b\n" "${CYAN}Fedora < 41 detected. Installing rpmfusion repos.${RC}"
|
printf "%b\n" "${CYAN}Fedora < 41 detected. Installing rpmfusion repos.${RC}"
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm -y
|
"$ESCALATION_TOOL" "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-"$(rpm -E %fedora)".noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-"$(rpm -E %fedora)".noarch.rpm -y
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 -y
|
"$ESCALATION_TOOL" "$PACKAGER" config-manager --enable fedora-cisco-openh264 -y
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
zypper)
|
zypper)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -n install "$DEPENDENCIES"
|
"$ESCALATION_TOOL" "$PACKAGER" -n install $DEPENDENCIES
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES"
|
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ installAdditionalDepend() {
|
||||||
case "$PACKAGER" in
|
case "$PACKAGER" in
|
||||||
pacman)
|
pacman)
|
||||||
DISTRO_DEPS='steam lutris goverlay'
|
DISTRO_DEPS='steam lutris goverlay'
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$DISTRO_DEPS"
|
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm $DISTRO_DEPS
|
||||||
;;
|
;;
|
||||||
apt-get|nala)
|
apt-get|nala)
|
||||||
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |
|
version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris |
|
||||||
|
|
|
@ -3,27 +3,29 @@
|
||||||
. ../common-script.sh
|
. ../common-script.sh
|
||||||
|
|
||||||
removeSnaps() {
|
removeSnaps() {
|
||||||
case "$PACKAGER" in
|
if command_exists snap; then
|
||||||
pacman)
|
case "$PACKAGER" in
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Rns snapd
|
pacman)
|
||||||
;;
|
"$ESCALATION_TOOL" "$PACKAGER" -Rns snapd
|
||||||
apt-get|nala)
|
;;
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd
|
apt-get|nala)
|
||||||
if [ "$ID" = ubuntu ]; then
|
"$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd
|
||||||
"$ESCALATION_TOOL" apt-mark hold snapd
|
if [ "$ID" = ubuntu ]; then
|
||||||
fi
|
"$ESCALATION_TOOL" apt-mark hold snapd
|
||||||
;;
|
fi
|
||||||
dnf)
|
;;
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
|
dnf|zypper)
|
||||||
;;
|
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
|
||||||
zypper)
|
;;
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
|
*)
|
||||||
;;
|
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||||
*)
|
exit 1
|
||||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
;;
|
||||||
exit 1
|
esac
|
||||||
;;
|
printf "%b\n" "${GREEN}Successfully removed snaps.${RC}"
|
||||||
esac
|
else
|
||||||
|
printf "%b\n" "${GREEN}Snapd is not installed.${RC}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
checkEnv
|
checkEnv
|
||||||
|
|
|
@ -23,7 +23,7 @@ cleanup_system() {
|
||||||
;;
|
;;
|
||||||
pacman)
|
pacman)
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
|
"$ESCALATION_TOOL" "$PACKAGER" -Sc --noconfirm
|
||||||
"$ESCALATION_TOOL" "$PACKAGER" -Rns "$(pacman -Qtdq)" --noconfirm
|
"$ESCALATION_TOOL" "$PACKAGER" -Rns $(pacman -Qtdq) --noconfirm > /dev/null 2>&1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||||
|
|
|
@ -16,60 +16,66 @@ values = [":0", ":1", ":2", ":3", ":4", ":5", ":6", ":7", ":8", ":9"]
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Auto Detect Displays"
|
name = "Auto Detect Displays"
|
||||||
description = "This utility is designed to detect and apply recommended configuration for monitors connected with your system"
|
description = "This script is designed to detect and apply recommended configuration for monitors connected with your system"
|
||||||
script = "monitor-control/auto_detect_displays.sh"
|
script = "monitor-control/auto_detect_displays.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Change Orientation"
|
name = "Change Orientation"
|
||||||
description = "This utility is designed to change the orientation of monitors in your system"
|
description = "This script is designed to change the orientation of monitors in your system"
|
||||||
script = "monitor-control/change_orientation.sh"
|
script = "monitor-control/change_orientation.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Disable Monitor"
|
name = "Disable Monitor"
|
||||||
description = "This utility is designed to disable a monitor in your system"
|
description = "This script is designed to disable a monitor in your system"
|
||||||
script = "monitor-control/disable_monitor.sh"
|
script = "monitor-control/disable_monitor.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Duplicate Displays"
|
name = "Duplicate Displays"
|
||||||
description = "This utility is designed to duplicate display among multi-monitor setup in your system"
|
description = "This script is designed to duplicate display among multi-monitor setup in your system"
|
||||||
script = "monitor-control/duplicate_displays.sh"
|
script = "monitor-control/duplicate_displays.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Enable Monitor"
|
name = "Enable Monitor"
|
||||||
description = "This utility is designed to enable a monitor in your system"
|
description = "This script is designed to enable a monitor in your system"
|
||||||
script = "monitor-control/enable_monitor.sh"
|
script = "monitor-control/enable_monitor.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Extend Displays"
|
name = "Extend Displays"
|
||||||
description = "This utility is designed to extend display among multi-monitor setup in your system"
|
description = "This script is designed to extend display among multi-monitor setup in your system"
|
||||||
script = "monitor-control/extend_displays.sh"
|
script = "monitor-control/extend_displays.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Manage Arrangement"
|
name = "Manage Arrangement"
|
||||||
description = "This utility is designed to arrange monitors in multi-monitor setup in your system"
|
description = "This script is designed to arrange monitors in multi-monitor setup in your system"
|
||||||
script = "monitor-control/manage_arrangement.sh"
|
script = "monitor-control/manage_arrangement.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Reset Scaling"
|
name = "Reset Scaling"
|
||||||
description = "This utility is designed to reset scaling of a monitor in your system"
|
description = "This script is designed to reset scaling of a monitor in your system"
|
||||||
script = "monitor-control/reset_scaling.sh"
|
script = "monitor-control/reset_scaling.sh"
|
||||||
matches = true
|
matches = true
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Scale Monitors"
|
name = "Scale Monitors"
|
||||||
description = "This utility is designed to change the scaling of monitors in your system"
|
description = "This script is designed to change the scaling of monitors in your system"
|
||||||
script = "monitor-control/scale_monitor.sh"
|
script = "monitor-control/scale_monitor.sh"
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Set Brightness"
|
name = "Set Brightness"
|
||||||
script = "monitor-control/set_brightness.sh"
|
script = "monitor-control/set_brightness.sh"
|
||||||
|
description = "This script is designed to change the Brightness of monitors connected to your system"
|
||||||
matches = true
|
matches = true
|
||||||
|
|
||||||
[[data.entries]]
|
[[data.entries]]
|
||||||
name = "Set Primary Monitor"
|
name = "Set Primary Monitor"
|
||||||
description = "This utility is designed to set a Primary monitor in your system"
|
description = "This script is designed to set a Primary monitor in your system"
|
||||||
script = "monitor-control/set_primary_monitor.sh"
|
script = "monitor-control/set_primary_monitor.sh"
|
||||||
|
|
||||||
|
[[data.entries]]
|
||||||
|
name = "Set Resolution"
|
||||||
|
description = "This script is designed to change the resolution of monitors connected to your system"
|
||||||
|
script = "monitor-control/set_resolutions.sh"
|
||||||
|
|
||||||
[[data]]
|
[[data]]
|
||||||
name = "User Account Manager"
|
name = "User Account Manager"
|
||||||
|
|
||||||
|
|
|
@ -61,13 +61,14 @@ Require linutil
|
||||||
Require sh
|
Require sh
|
||||||
|
|
||||||
Set Shell "bash"
|
Set Shell "bash"
|
||||||
Set FontSize 32
|
Set FontFamily "JetBrainsMono Nerd Font"
|
||||||
Set Width 3200
|
Set FontSize 24
|
||||||
Set Height 1800
|
Set Width 1920
|
||||||
|
Set Height 1080
|
||||||
|
|
||||||
Sleep 1s
|
Sleep 1s
|
||||||
|
|
||||||
Type "linutil -t compatible" Sleep 1s Enter
|
Type "linutil" Sleep 1s Enter
|
||||||
|
|
||||||
Sleep 5s
|
Sleep 5s
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Linutil
|
Name=Linutil
|
||||||
Exec=sh -c "$HOME/.local/bin/linutil"
|
Comment=Distro-agnostic toolbox designed to simplify everyday Linux tasks
|
||||||
|
Exec=sh -c '/usr/bin/linutil || $HOME/.cargo/bin/linutil || linutil'
|
||||||
Icon=utilities-terminal
|
Icon=utilities-terminal
|
||||||
Type=Application
|
Type=Application
|
||||||
Terminal=true
|
Terminal=true
|
||||||
Categories=Utility;
|
Categories=Utility;
|
||||||
|
|
4
start.sh
4
start.sh
|
@ -14,8 +14,8 @@ check() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset exit_code
|
unset exit_code
|
||||||
unset message
|
unset message
|
||||||
}
|
}
|
||||||
|
|
||||||
findArch() {
|
findArch() {
|
||||||
|
|
|
@ -15,7 +15,7 @@ default = ["tips"]
|
||||||
tips = ["rand"]
|
tips = ["rand"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.5.18", features = ["derive", "std"], default-features = false }
|
clap = { version = "4.5.19", features = ["derive", "std"], default-features = false }
|
||||||
crossterm = { version = "0.28.1", default-features = false }
|
crossterm = { version = "0.28.1", default-features = false }
|
||||||
ego-tree = { workspace = true }
|
ego-tree = { workspace = true }
|
||||||
oneshot = { version = "0.1.8", features = ["std"], default-features = false }
|
oneshot = { version = "0.1.8", features = ["std"], default-features = false }
|
||||||
|
@ -26,7 +26,7 @@ temp-dir = "0.1.14"
|
||||||
unicode-width = { version = "0.2.0", default-features = false }
|
unicode-width = { version = "0.2.0", default-features = false }
|
||||||
rand = { version = "0.8.5", optional = true }
|
rand = { version = "0.8.5", optional = true }
|
||||||
linutil_core = { version = "24.9.28", path = "../core" }
|
linutil_core = { version = "24.9.28", path = "../core" }
|
||||||
tree-sitter-highlight = "0.23.0"
|
tree-sitter-highlight = "0.24.2"
|
||||||
tree-sitter-bash = "0.23.1"
|
tree-sitter-bash = "0.23.1"
|
||||||
anstyle = { version = "1.0.8", default-features = false }
|
anstyle = { version = "1.0.8", default-features = false }
|
||||||
ansi-to-tui = { version = "6.0.0", default-features = false }
|
ansi-to-tui = { version = "6.0.0", default-features = false }
|
||||||
|
|
|
@ -24,18 +24,12 @@ use tree_sitter_bash as hl_bash;
|
||||||
use tree_sitter_highlight::{self as hl, HighlightEvent};
|
use tree_sitter_highlight::{self as hl, HighlightEvent};
|
||||||
use zips::zip_result;
|
use zips::zip_result;
|
||||||
|
|
||||||
pub enum FloatingTextMode {
|
|
||||||
Preview,
|
|
||||||
Description,
|
|
||||||
ActionsGuide,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct FloatingText {
|
pub struct FloatingText {
|
||||||
pub src: Vec<String>,
|
pub src: Vec<String>,
|
||||||
max_line_width: usize,
|
max_line_width: usize,
|
||||||
v_scroll: usize,
|
v_scroll: usize,
|
||||||
h_scroll: usize,
|
h_scroll: usize,
|
||||||
mode_title: &'static str,
|
mode_title: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! style {
|
macro_rules! style {
|
||||||
|
@ -130,7 +124,7 @@ fn get_lines_owned(s: &str) -> Vec<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FloatingText {
|
impl FloatingText {
|
||||||
pub fn new(text: String, mode: FloatingTextMode) -> Self {
|
pub fn new(text: String, title: &str) -> Self {
|
||||||
let src = get_lines(&text)
|
let src = get_lines(&text)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| s.to_string())
|
.map(|s| s.to_string())
|
||||||
|
@ -139,14 +133,14 @@ impl FloatingText {
|
||||||
let max_line_width = max_width!(src);
|
let max_line_width = max_width!(src);
|
||||||
Self {
|
Self {
|
||||||
src,
|
src,
|
||||||
mode_title: Self::get_mode_title(mode),
|
mode_title: title.to_string(),
|
||||||
max_line_width,
|
max_line_width,
|
||||||
v_scroll: 0,
|
v_scroll: 0,
|
||||||
h_scroll: 0,
|
h_scroll: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_command(command: &Command, mode: FloatingTextMode) -> Option<Self> {
|
pub fn from_command(command: &Command, title: String) -> Option<Self> {
|
||||||
let (max_line_width, src) = match command {
|
let (max_line_width, src) = match command {
|
||||||
Command::Raw(cmd) => {
|
Command::Raw(cmd) => {
|
||||||
// just apply highlights directly
|
// just apply highlights directly
|
||||||
|
@ -169,21 +163,13 @@ impl FloatingText {
|
||||||
|
|
||||||
Some(Self {
|
Some(Self {
|
||||||
src,
|
src,
|
||||||
mode_title: Self::get_mode_title(mode),
|
mode_title: title,
|
||||||
max_line_width,
|
max_line_width,
|
||||||
h_scroll: 0,
|
h_scroll: 0,
|
||||||
v_scroll: 0,
|
v_scroll: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mode_title(mode: FloatingTextMode) -> &'static str {
|
|
||||||
match mode {
|
|
||||||
FloatingTextMode::Preview => "Command Preview",
|
|
||||||
FloatingTextMode::Description => "Command Description",
|
|
||||||
FloatingTextMode::ActionsGuide => "Important Actions Guide",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn scroll_down(&mut self) {
|
fn scroll_down(&mut self) {
|
||||||
if self.v_scroll + 1 < self.src.len() {
|
if self.v_scroll + 1 < self.src.len() {
|
||||||
self.v_scroll += 1;
|
self.v_scroll += 1;
|
||||||
|
@ -214,7 +200,7 @@ impl FloatContent for FloatingText {
|
||||||
// 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)
|
||||||
.title(self.mode_title)
|
.title(self.mode_title.clone())
|
||||||
.title_alignment(ratatui::layout::Alignment::Center)
|
.title_alignment(ratatui::layout::Alignment::Center)
|
||||||
.title_style(Style::default().reversed())
|
.title_style(Style::default().reversed())
|
||||||
.style(Style::default());
|
.style(Style::default());
|
||||||
|
@ -292,7 +278,7 @@ impl FloatContent for FloatingText {
|
||||||
|
|
||||||
fn get_shortcut_list(&self) -> (&str, Box<[Shortcut]>) {
|
fn get_shortcut_list(&self) -> (&str, Box<[Shortcut]>) {
|
||||||
(
|
(
|
||||||
self.mode_title,
|
&self.mode_title,
|
||||||
Box::new([
|
Box::new([
|
||||||
Shortcut::new("Scroll down", ["j", "Down"]),
|
Shortcut::new("Scroll down", ["j", "Down"]),
|
||||||
Shortcut::new("Scroll up", ["k", "Up"]),
|
Shortcut::new("Scroll up", ["k", "Up"]),
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
confirmation::{ConfirmPrompt, ConfirmStatus},
|
confirmation::{ConfirmPrompt, ConfirmStatus},
|
||||||
filter::{Filter, SearchAction},
|
filter::{Filter, SearchAction},
|
||||||
float::{Float, FloatContent},
|
float::{Float, FloatContent},
|
||||||
floating_text::{FloatingText, FloatingTextMode},
|
floating_text::FloatingText,
|
||||||
hint::{create_shortcut_list, Shortcut},
|
hint::{create_shortcut_list, Shortcut},
|
||||||
running_command::RunningCommand,
|
running_command::RunningCommand,
|
||||||
theme::Theme,
|
theme::Theme,
|
||||||
|
@ -21,6 +19,7 @@ use ratatui::{
|
||||||
widgets::{Block, Borders, List, ListState, Paragraph},
|
widgets::{Block, Borders, List, ListState, Paragraph},
|
||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
use std::rc::Rc;
|
||||||
use temp_dir::TempDir;
|
use temp_dir::TempDir;
|
||||||
|
|
||||||
const MIN_WIDTH: u16 = 77;
|
const MIN_WIDTH: u16 = 77;
|
||||||
|
@ -54,7 +53,7 @@ pub struct AppState {
|
||||||
/// 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>,
|
||||||
/// This is the state asociated 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,
|
||||||
filter: Filter,
|
filter: Filter,
|
||||||
|
@ -655,10 +654,10 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enable_preview(&mut self) {
|
fn enable_preview(&mut self) {
|
||||||
if let Some(node) = self.get_selected_node() {
|
if let Some(list_node) = self.get_selected_node() {
|
||||||
if let Some(preview) =
|
let mut preview_title = "[Preview] - ".to_string();
|
||||||
FloatingText::from_command(&node.command, FloatingTextMode::Preview)
|
preview_title.push_str(list_node.name.as_str());
|
||||||
{
|
if let Some(preview) = FloatingText::from_command(&list_node.command, preview_title) {
|
||||||
self.spawn_float(preview, 80, 80);
|
self.spawn_float(preview, 80, 80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +665,7 @@ 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, FloatingTextMode::Description);
|
let description = FloatingText::new(command_description, "Command Description");
|
||||||
self.spawn_float(description, 80, 80);
|
self.spawn_float(description, 80, 80);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -732,7 +731,7 @@ impl AppState {
|
||||||
|
|
||||||
fn toggle_task_list_guide(&mut self) {
|
fn toggle_task_list_guide(&mut self) {
|
||||||
self.spawn_float(
|
self.spawn_float(
|
||||||
FloatingText::new(ACTIONS_GUIDE.to_string(), FloatingTextMode::ActionsGuide),
|
FloatingText::new(ACTIONS_GUIDE.to_string(), "Important Actions Guide"),
|
||||||
80,
|
80,
|
||||||
80,
|
80,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user