Открыть боковую панель
cgfrosty
school-ringer
Коммиты
64c333dc
Коммит
64c333dc
создал
Дек 26, 2023
по автору
Леляев Петр Алексеевич
Просмотр файлов
Параметры воспроизведения музыки на переменах читаются из файла конфига
владелец
4eaedbfd
Изменения
2
Скрыть пробелы
Построчно
Рядом
school_ringer_modules/settings.py
Просмотр файла @
64c333dc
...
...
@@ -253,28 +253,33 @@ class CallsSettings(QWidget):
self
.
holidays_editing_window
=
CalendarEditor
()
def
play_music_on_breaks
(
self
):
if
self
.
play_music_on_breaks_btn
.
text
()
==
'Играть музыку на переменах'
:
# если музыка отключена
if
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main is_breaks_music_on'
).
strip
()
!=
'true'
:
dlg
=
PlayMusicOnBreaksDialog
(
self
)
if
dlg
.
exec
()
==
QDialog
.
Accepted
and
dlg
.
music_folder
:
if
dlg
.
exec
()
==
QDialog
.
Accepted
:
music_folder
=
dlg
.
music_folder
.
strip
()
if
dlg
.
music_folder
else
\
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main music_folder'
).
strip
()
self
.
music_playing_thread
.
songs_list
=
[
f
'"
{
dlg
.
music_folder
}
/
{
i
}
"'
for
i
in
os
.
listdir
(
dlg
.
music_folder
)
if
(
f
'"
{
music_folder
}
/
{
i
}
"'
for
i
in
os
.
listdir
(
music_folder
)
if
(
i
.
endswith
(
'.mp3'
)
or
i
.
endswith
(
'.ogg'
)
or
i
.
endswith
(
'.wav'
)
)]
if
dlg
.
shuffle_checkbox
.
isChecked
():
shuffle
(
self
.
music_playing_thread
.
songs_list
)
self
.
music_playing_thread
.
start
()
self
.
play_music_on_breaks_btn
.
setText
(
'Не играть музыку'
)
self
.
real_music_on_breaks_status_label
.
setText
(
f
'Играет из папки
{
music_folder
}
'
)
self
.
is_breaks_music_on
=
True
run_command
(
f
'pkexec sh -c "py-ini-config set '
f
'
{
config_path
}
/school-ringer.conf Main is_breaks_music_on true && '
f
'py-ini-config set '
f
'
{
config_path
}
/school-ringer.conf Main music_folder "
{
dlg
.
music_folder
}
" && '
f
'
{
config_path
}
/school-ringer.conf Main music_folder "
{
music_folder
}
" && '
f
'py-ini-config set '
f
'
{
config_path
}
/school-ringer.conf Main music_shuffle
{
dlg
.
shuffle_checkbox
.
isChecked
()
}
"'
)
else
:
self
.
music_playing_thread
.
terminate
()
subprocess
.
run
(
'pkill play'
,
shell
=
True
)
self
.
play_music_on_breaks_btn
.
setText
(
'Играть музыку на переменах'
)
self
.
real_music_on_breaks_status_label
.
setText
(
f
'Отключена'
)
self
.
is_breaks_music_on
=
False
run_command
(
f
'pkexec sh -c '
f
'"py-ini-config set
{
config_path
}
/school-ringer.conf Main is_breaks_music_on false"'
)
...
...
@@ -331,7 +336,7 @@ class CallsSettings(QWidget):
label_music_on_breaks_status
.
setStyleSheet
(
"QLabel {font-weight: bold;}"
)
grid
.
addWidget
(
label_music_on_breaks_status
,
4
,
1
)
self
.
real_music_on_breaks_status_label
=
QLabel
()
if
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main
play
_music'
).
strip
()
!=
'true'
:
if
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main
is_breaks
_music
_on
'
).
strip
()
!=
'true'
:
self
.
real_music_on_breaks_status_label
.
setText
(
'Отключена'
)
else
:
music_folder
=
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main music_folder'
).
strip
()
...
...
@@ -363,7 +368,11 @@ class CallsSettings(QWidget):
btn_edit_calendar
.
setMinimumHeight
(
40
)
btn_edit_calendar
.
clicked
.
connect
(
self
.
edit_calendar
)
grid
.
addWidget
(
btn_edit_calendar
,
9
,
1
,
1
,
2
)
self
.
play_music_on_breaks_btn
=
QPushButton
(
'Играть музыку на переменах'
)
self
.
play_music_on_breaks_btn
=
QPushButton
(
''
)
if
run_command
(
f
'py-ini-config get
{
config_path
}
/school-ringer.conf Main is_breaks_music_on'
).
strip
()
==
'true'
:
self
.
play_music_on_breaks_btn
.
setText
(
'Не играть музыку'
)
else
:
self
.
play_music_on_breaks_btn
.
setText
(
'Играть музыку на переменах'
)
self
.
play_music_on_breaks_btn
.
setMinimumHeight
(
40
)
self
.
play_music_on_breaks_btn
.
clicked
.
connect
(
self
.
play_music_on_breaks
)
grid
.
addWidget
(
self
.
play_music_on_breaks_btn
,
10
,
1
,
1
,
2
)
...
...
school_ringer_modules/system.py
Просмотр файла @
64c333dc
...
...
@@ -49,3 +49,21 @@ def authority_check(action_id="ru.mos.os.school-ringer"):
if
result
[
0
]
==
0
:
print
(
'Авторизация не пройдена!'
)
return
result
[
0
]
#
# def get_music_config():
# res = {
# 'is_breaks_music_on': False,
# 'music_folder': '/home',
# 'music_shuffle': False
# }
# with open(f'{config_path}/school-ringer.conf', 'r') as inp:
# lines = inp.readlines()
# for line in lines:
# if line.strip().startswith('is_breaks_music_on'):
# res['is_breaks_music_on'] = line.strip().split('=')[-1].strip()
# if line.strip().startswith('music_folder'):
# res['music_folder'] = line.strip().split('=')[-1].strip()
# if line.strip().startswith('music_shuffle'):
# res['music_shuffle'] = line.strip().split('=')[-1].strip()
# return res
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать