Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-unified-theme-switcher
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
Алексей Николаевич Пахомкин
ximper-unified-theme-switcher
Commits
0acb99f7
Commit
0acb99f7
authored
Sep 09, 2024
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the whether to enable the service dialog
parent
fa2346eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
1 deletion
+55
-1
ru.po
po/ru.po
+12
-0
main.py
src/main.py
+31
-0
utils.py
src/utils.py
+12
-1
No files found.
po/ru.po
View file @
0acb99f7
...
...
@@ -31,3 +31,15 @@ msgstr "Тёмная"
msgid "Dark Style"
msgstr "Тёмный Стиль"
msgid "Yes"
msgstr "Да"
msgid "No"
msgstr "Нет"
msgid "The user service is disabled."
msgstr "Юзер-сервис выключен."
msgid "Do you want to enable it?"
msgstr "Вы бы хотели включить его?"
src/main.py
View file @
0acb99f7
import
sys
,
os
import
gi
from
.utils
import
service_status
,
service_enable
,
_
gi
.
require_version
(
'Gtk'
,
'4.0'
)
gi
.
require_version
(
'Adw'
,
'1'
)
...
...
@@ -28,6 +29,36 @@ class XimperUnifiedThemeSwitcherGuiGtk4Application(Adw.Application):
if
not
win
:
win
=
XimperUnifiedThemeSwitcherGuiGtk4Window
(
application
=
self
)
win
.
present
()
if
service_status
(
"ximper-unified-theme-switcher.service"
)
==
False
:
print
(
"service not found"
)
# Create the dialog
dialog
=
Adw
.
AlertDialog
(
heading
=
_
(
"The user service is disabled."
),
body
=
_
(
"Do you want to enable it?"
)
)
# Add buttons for the user to respond
dialog
.
add_response
(
"yes"
,
_
(
"Yes"
))
dialog
.
add_response
(
"no"
,
_
(
"No"
))
# Connect the response handler
dialog
.
connect
(
"response"
,
self
.
srvs_d_on_response
)
# Present the dialog
dialog
.
present
(
win
)
def
srvs_d_on_response
(
self
,
dialog
,
response
):
print
(
f
"response: {response}"
)
if
response
==
"yes"
:
service_enable
(
"ximper-unified-theme-switcher.service"
)
dialog
.
close
()
elif
response
in
(
"no"
,
"close"
):
dialog
.
close
()
self
.
props
.
active_window
.
close
()
def
on_about_action
(
self
,
widget
,
_
):
"""Callback for the app.about action."""
...
...
src/utils.py
View file @
0acb99f7
...
...
@@ -8,6 +8,10 @@ gi.require_version('Adw', '1')
from
gi.repository
import
Gtk
import
gettext
gettext
.
textdomain
(
'ximper-unified-theme-switcher-gui'
)
_
=
gettext
.
gettext
SYSTEM_CONFIG_DIR
=
"/etc/ximper-unified-theme-switcher"
SYSTEM_CONFIG_FILE
=
os
.
path
.
join
(
SYSTEM_CONFIG_DIR
,
"themes"
)
...
...
@@ -161,7 +165,7 @@ def configure_cr_widgets(crs_configurations, selected_func):
def
service_status
(
service_name
):
try
:
# Запускаем команду systemctl is-active <service_name>
result
=
subprocess
.
run
([
'systemctl'
,
'is-active'
,
service_name
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
result
=
subprocess
.
run
([
'systemctl'
,
'
--user'
,
'
is-active'
,
service_name
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
# Проверяем статус
if
result
.
stdout
.
decode
(
'utf-8'
)
.
strip
()
==
'active'
:
return
True
...
...
@@ -170,3 +174,10 @@ def service_status(service_name):
except
Exception
as
e
:
print
(
f
"An error occurred: {e}"
)
return
False
def
service_enable
(
service_name
):
try
:
subprocess
.
run
([
'systemctl'
,
'--user'
,
'--now'
,
'enable'
,
service_name
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
except
Exception
as
e
:
print
(
f
"An error occurred: {e}"
)
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