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
fa440cef
Commit
fa440cef
authored
Mar 29, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
0 deletions
+101
-0
PPpMGR.sh
PPpMGR.sh
+101
-0
No files found.
PPpMGR.sh
0 → 100755
View file @
fa440cef
#!/bin/bash
PPpMGR_RANDOM
=
"
${
RANDOM
}
"
valid_fs
=(
"btrfs"
"ext4"
)
# Проверяем, установлено ли yad
if
!
command
-v
yad &> /dev/null
;
then
echo
"Необходимо установить yad. Запустите 'sudo apt-get install yad' для установки."
exit
1
fi
PP_default_prefixes_directory
=
"
$HOME
/PortProton/prefixes"
percent_bar
()
{
local
percentage
=
$(
echo
"
$1
"
|
sed
's/%//'
)
local
total
=
$2
local
filled
=
$(
echo
"(
$percentage
*
$total
)/100"
| bc
)
local
empty
=
$((
total-filled
))
printf
"["
for
((
i
=
0
;
i<filled
;
i++
))
;
do
printf
"▇"
done
for
((
i
=
0
;
i<empty
;
i++
))
;
do
printf
"_"
done
printf
"]"
}
PP_default_prefixes_directory
=
"
$HOME
/PortProton/prefixes"
pfxparce
()
{
target_directory
=
"
$1
"
for
entry
in
$PP_default_prefixes_directory
/
*
do
# Проверяем, является ли элемент директорией
if
[
-d
"
$entry
"
]
;
then
# Получаем полный путь к директории
real_path
=
$(
realpath
"
$entry
"
)
# Проверяем, содержит ли путь указанную точку
if
[[
"
$real_path
"
=
~
"
$target_directory
"
]]
;
then
# Извлекаем имя префикса и его реальный путь
prefix_name
=
$(
basename
$entry
)
echo
"
$prefix_name
|
$real_path
"
fi
fi
done
}
gui
()
{
[[
-z
"
$(
which yad
)
"
]]
&&
echo
'You need to install "yad" in your system.'
&&
exit
1
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
IFS
=
$' '
read
-r
mnt_name mnt_fstype occupancy_percent
<<<
"
$tab
"
local
PPpMGR_BUTTONS
=()
if
[[
"
${
valid_fs
[@]
}
"
=
~
"
$mnt_fstype
"
]]
;
then
echo
"Found valid filesystem:
$mnt_fstype
"
else
echo
"Invalid filesystem:
$mnt_fstype
, continuing..."
continue
fi
prefixes_in_mnt
=
$(
pfxparce
"
$mnt_name
"
)
IFS
=
$'
\n
'
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"
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"
((
tab_count++
))
yad
--plug
=
"
$PPpMGR_RANDOM
"
--tabnum
=
$tab_count
--form
\
--separator
=
'|'
\
--field
=
"Занято на диске
$occupancy_percent
:
\n\
$occupancy_percent_bar
:LBL"
\
\
--field
=
"Тип файловой системы:
$mnt_fstype
:LBL"
\
\
\
${
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
YAD_STATUS
=
"
$?
"
IFS
=
${
old_IFS
}
[[
"
$YAD_STATUS
"
==
"1"
||
"
$YAD_STATUS
"
==
"252"
]]
&&
exit
0
}
gui
\ No newline at end of file
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