Commit 11589f1c authored by Roman Alifanov's avatar Roman Alifanov

some shellcheck and others fixes

parent f8db4c5a
#!/bin/bash
# shellcheck disable=SC2155
# shellcheck disable=SC2001
# shellcheck disable=SC2048
PPpMGR_RANDOM="${RANDOM}"
valid_fs=("btrfs" "ext4")
# Проверяем, установлено ли yad
......@@ -8,9 +11,9 @@ if ! command -v yad &> /dev/null; then
fi
if [[ -d "$HOME/.var/app/ru.linux_gaming.PortProton/" ]]; then
PP_default_prefixes_directory="$HOME/.var/app/ru.linux_gaming.PortProton/"
PP_default_prefixes_directory="$HOME/.var/app/ru.linux_gaming.PortProton/prefixes"
else
PP_default_prefixes_directory="$(cat $HOME/.config/PortProton.conf)"
PP_default_prefixes_directory="$(cat "$HOME"/.config/PortProton.conf)/prefixes"
fi
percent_bar() {
......@@ -29,12 +32,10 @@ percent_bar() {
printf "]"
}
PP_default_prefixes_directory="$HOME/PortProton/prefixes"
pfxparse() {
target_directory="$1"
for entry in $PP_default_prefixes_directory/*
for entry in "$PP_default_prefixes_directory"/*
do
# Проверяем, является ли элемент директорией
if [ -d "$entry" ]; then
......@@ -42,9 +43,9 @@ pfxparse() {
real_path=$(realpath "$entry")
# Проверяем, содержит ли путь указанную точку
if [[ "$real_path" =~ "$target_directory" ]]; then
if [[ "$real_path" =~ $target_directory ]]; then
# Извлекаем имя префикса и его реальный путь
prefix_name=$(basename $entry)
prefix_name=$(basename "$entry")
echo "$prefix_name|$real_path"
fi
fi
......@@ -55,11 +56,11 @@ gui() {
old_IFS=$IFS && IFS=$'|'
local tab_count=0
for tab in $(df -T "$HOME" /mnt/* /run/media/$USER/* | tail -n +2 | awk '{printf "%s %s %s|", $7,$2,$6}') ; do
for tab in $(df -T "$HOME" /mnt/* /run/media/"$USER"/* | tail -n +2 | awk '{printf "%s %s %s|", $7,$2,$6}') ; do
IFS=$' ' read -r mnt_name mnt_fstype occupancy_percent <<< "$tab"
local PPpMGR_BUTTONS=()
if [[ "${valid_fs[@]}" =~ "$mnt_fstype" ]]; then
if [[ "${valid_fs[*]}" =~ $mnt_fstype ]]; then
echo "Found valid filesystem: $mnt_fstype"
else
echo "Invalid filesystem: $mnt_fstype, continuing..."
......@@ -71,12 +72,12 @@ gui() {
for pfx in $prefixes_in_mnt ; do
((button_count++))
IFS=$'|' read -r pfx_name pfx_dir <<< "$pfx"
local PPpMGR_BUTTONS[$button_count]="--field=$pfx_name:FBTN"
local PPpMGR_BUTTONS[button_count]="--field=$pfx_name:FBTN"
done
echo "$prefixes_in_mnt"
local occupancy_percent_bar=$(percent_bar "$occupancy_percent" "25")
local PPpMGR_TAB[$tab_count]="--tab= $(echo $mnt_name | sed 's/_/ /') !drive-harddisk"
local occupancy_percent_bar="$(percent_bar "$occupancy_percent" "25")"
local PPpMGR_TAB[tab_count]="--tab= $(echo "$mnt_name" | sed 's/_/ /') !drive-harddisk"
((tab_count++))
yad --plug="$PPpMGR_RANDOM" --tabnum=$tab_count --form \
......@@ -87,14 +88,14 @@ gui() {
--field="Тип файловой системы: $mnt_fstype:LBL" \
\
\
${PPpMGR_BUTTONS[@]} \
${PPpMGR_BUTTONS[*]} \
\
2>/dev/null &
done
yad --key=$PPpMGR_RANDOM --class=PortProton --notebook --borders=3 --width=200 --height=400 \
--title "PPpMGR" --tab-pos=left ${PPpMGR_TAB[@]} 2>/dev/null
--title "PPpMGR" --tab-pos=left ${PPpMGR_TAB[*]} 2>/dev/null
YAD_STATUS="$?"
IFS=${old_IFS}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment