Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
PortProton_prefix_ManaGeR
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roman Alifanov
PortProton_prefix_ManaGeR
Commits
11589f1c
Commit
11589f1c
authored
Mar 29, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some shellcheck and others fixes
parent
f8db4c5a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
PPpMGR.sh
PPpMGR.sh
+15
-14
No files found.
PPpMGR.sh
View file @
11589f1c
#!/bin/bash
#!/bin/bash
# shellcheck disable=SC2155
# shellcheck disable=SC2001
# shellcheck disable=SC2048
PPpMGR_RANDOM
=
"
${
RANDOM
}
"
PPpMGR_RANDOM
=
"
${
RANDOM
}
"
valid_fs
=(
"btrfs"
"ext4"
)
valid_fs
=(
"btrfs"
"ext4"
)
# Проверяем, установлено ли yad
# Проверяем, установлено ли yad
...
@@ -8,9 +11,9 @@ if ! command -v yad &> /dev/null; then
...
@@ -8,9 +11,9 @@ if ! command -v yad &> /dev/null; then
fi
fi
if
[[
-d
"
$HOME
/.var/app/ru.linux_gaming.PortProton/"
]]
;
then
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
else
PP_default_prefixes_directory
=
"
$(
cat
$HOME
/.config/PortProton.conf
)
"
PP_default_prefixes_directory
=
"
$(
cat
"
$HOME
"
/.config/PortProton.conf
)
/prefixes
"
fi
fi
percent_bar
()
{
percent_bar
()
{
...
@@ -29,12 +32,10 @@ percent_bar() {
...
@@ -29,12 +32,10 @@ percent_bar() {
printf
"]"
printf
"]"
}
}
PP_default_prefixes_directory
=
"
$HOME
/PortProton/prefixes"
pfxparse
()
{
pfxparse
()
{
target_directory
=
"
$1
"
target_directory
=
"
$1
"
for
entry
in
$PP_default_prefixes_directory
/
*
for
entry
in
"
$PP_default_prefixes_directory
"
/
*
do
do
# Проверяем, является ли элемент директорией
# Проверяем, является ли элемент директорией
if
[
-d
"
$entry
"
]
;
then
if
[
-d
"
$entry
"
]
;
then
...
@@ -42,9 +43,9 @@ pfxparse() {
...
@@ -42,9 +43,9 @@ pfxparse() {
real_path
=
$(
realpath
"
$entry
"
)
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
"
echo
"
$prefix_name
|
$real_path
"
fi
fi
fi
fi
...
@@ -55,11 +56,11 @@ gui() {
...
@@ -55,11 +56,11 @@ gui() {
old_IFS
=
$IFS
&&
IFS
=
$'|'
old_IFS
=
$IFS
&&
IFS
=
$'|'
local
tab_count
=
0
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
"
IFS
=
$' '
read
-r
mnt_name mnt_fstype occupancy_percent
<<<
"
$tab
"
local
PPpMGR_BUTTONS
=()
local
PPpMGR_BUTTONS
=()
if
[[
"
${
valid_fs
[
@]
}
"
=
~
"
$mnt_fstype
"
]]
;
then
if
[[
"
${
valid_fs
[
*]
}
"
=
~
$mnt_fstype
]]
;
then
echo
"Found valid filesystem:
$mnt_fstype
"
echo
"Found valid filesystem:
$mnt_fstype
"
else
else
echo
"Invalid filesystem:
$mnt_fstype
, continuing..."
echo
"Invalid filesystem:
$mnt_fstype
, continuing..."
...
@@ -71,12 +72,12 @@ gui() {
...
@@ -71,12 +72,12 @@ gui() {
for
pfx
in
$prefixes_in_mnt
;
do
for
pfx
in
$prefixes_in_mnt
;
do
((
button_count++
))
((
button_count++
))
IFS
=
$'|'
read
-r
pfx_name pfx_dir
<<<
"
$pfx
"
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
done
echo
"
$prefixes_in_mnt
"
echo
"
$prefixes_in_mnt
"
local
occupancy_percent_bar
=
$(
percent_bar
"
$occupancy_percent
"
"25"
)
local
occupancy_percent_bar
=
"
$(
percent_bar
"
$occupancy_percent
"
"25"
)
"
local
PPpMGR_TAB[
$tab_count
]=
"--tab=
$(
echo
$mnt_name
|
sed
's/_/ /'
)
!drive-harddisk"
local
PPpMGR_TAB[
tab_count]
=
"--tab=
$(
echo
"
$mnt_name
"
|
sed
's/_/ /'
)
!drive-harddisk"
((
tab_count++
))
((
tab_count++
))
yad
--plug
=
"
$PPpMGR_RANDOM
"
--tabnum
=
$tab_count
--form
\
yad
--plug
=
"
$PPpMGR_RANDOM
"
--tabnum
=
$tab_count
--form
\
...
@@ -87,14 +88,14 @@ gui() {
...
@@ -87,14 +88,14 @@ gui() {
--field
=
"Тип файловой системы:
$mnt_fstype
:LBL"
\
--field
=
"Тип файловой системы:
$mnt_fstype
:LBL"
\
\
\
\
\
${
PPpMGR_BUTTONS
[
@
]
}
\
${
PPpMGR_BUTTONS
[
*
]
}
\
\
\
2>/dev/null &
2>/dev/null &
done
done
yad
--key
=
$PPpMGR_RANDOM
--class
=
PortProton
--notebook
--borders
=
3
--width
=
200
--height
=
400
\
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
=
"
$?
"
YAD_STATUS
=
"
$?
"
IFS
=
${
old_IFS
}
IFS
=
${
old_IFS
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment