-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding hyprland to available desktops and configs *i also fixed the logout button* #336
Changes from 14 commits
4084f59
3e9865b
a3b174a
2945011
3856bae
24511a2
3675dd6
a725806
c93eb37
b48bd09
2ae7d59
4b8f020
3b30e77
f5b8860
147cc36
c053578
5ac2477
3cb3c9a
caf50a8
efeb82d
12377fc
480c171
f5af0c7
35e74e7
d2c09d8
cdfc16d
acc313e
b475151
a235dc6
1c7048d
4bcd124
f40b173
40832aa
673dbdc
4460041
e084d80
307d410
7fdf1ef
37c5018
5417792
ce8c4f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,15 +1,17 @@ | ||||||
import os, json, gi, argparse, shutil | ||||||
from gi.repository import GLib, Gio | ||||||
from localization import _, CACHE, DATA, home, system_dir, flatpak, snap, settings | ||||||
|
||||||
# add command-line arguments | ||||||
from localization import _, CACHE, DATA, system_dir, flatpak, snap, settings | ||||||
home = os.getenv('HOME') | ||||||
#add command-line arguments | ||||||
parser = argparse.ArgumentParser() | ||||||
parser.add_argument("-s", "--save", help="Save the current configuration", action="store_true") | ||||||
parser.add_argument("-i", "--import_", help="Import saved configuration", action="store_true") | ||||||
|
||||||
args = parser.parse_args() | ||||||
|
||||||
# check of the user's current DE | ||||||
#creating a lambda functin to get the path to the package config folder | ||||||
pathto=lambda package:home+'/.config/'+package | ||||||
pyclicker marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
#check of the user's current DE | ||||||
if os.getenv('XDG_CURRENT_DESKTOP') == 'GNOME': | ||||||
environment = 'GNOME' | ||||||
elif os.getenv('XDG_CURRENT_DESKTOP') == 'zorin:GNOME': | ||||||
|
@@ -34,8 +36,10 @@ | |||||
environment = 'KDE Plasma' | ||||||
elif os.getenv('XDG_CURRENT_DESKTOP') == 'Deepin': | ||||||
environment = 'Deepin' | ||||||
else: | ||||||
from tty_environments import * | ||||||
elif os.getenv('XDG_CURRENT_DESKTOP') == 'Hyprland': | ||||||
environment = 'Hyprland' | ||||||
#else: | ||||||
# from tty_environments import * | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tty_environments.py file is used to detect DE if SaveDesktop is running in TTY mode (i.e. pure CLI without graphical environment or tile WM) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i do not know why i deleted that ...... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
|
||||||
class Save: | ||||||
def __init__(self): | ||||||
|
@@ -76,7 +80,7 @@ def __init__(self): | |||||
if settings["save-flatpak-data"] == True: | ||||||
print("saving user data of installed Flatpak apps") | ||||||
self.save_flatpak_data() | ||||||
|
||||||
print("saving desktop environment configuration files") | ||||||
# Save configs on individual desktop environments | ||||||
if environment == 'GNOME': | ||||||
|
@@ -136,7 +140,9 @@ def __init__(self): | |||||
elif environment == 'Deepin': | ||||||
os.system(f"cp -R {home}/.config/deepin ./") | ||||||
os.system(f"cp -R {home}/.local/share/deepin ./deepin-data") | ||||||
|
||||||
elif environment == 'Hyprland': | ||||||
shutil.copytree(f"{home}/.config/hypr","./hypr",dirs_exist_ok=True) | ||||||
|
||||||
# save Flatpak apps data | ||||||
def save_flatpak_data(self): | ||||||
blst = settings["disabled-flatpak-apps-data"] | ||||||
|
@@ -248,7 +254,9 @@ def __init__(self): | |||||
elif environment == 'Deepin': | ||||||
os.system(f"cp -au ./deepin {home}/.config/") | ||||||
os.system(f"cp -au ./deepin-data {home}/.local/share/deepin/") | ||||||
elif environment == None: | ||||||
elif environment == 'Hyprland': | ||||||
os.system(f"cp -aur ./hypr {home}/.config/ -v") | ||||||
elif environment == None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This row is not aligned correctly, which generates a TabError. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
print("→ SKIPPING: SaveDesktop is running in the TTY mode") | ||||||
|
||||||
if flatpak: | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -118,7 +118,8 @@ def __init__(self, *args, **kwargs): | |||||
'XFCE': 'Xfce', | ||||||
'MATE': 'MATE', | ||||||
'KDE': 'KDE Plasma', | ||||||
'Deepin': 'Deepin' | ||||||
'Deepin': 'Deepin', | ||||||
'Hyprland': 'Hyprland' | ||||||
} | ||||||
|
||||||
# If the user has a supported environment, it shows the app window, otherwise, it shows the window with information about an unsupported environment | ||||||
|
@@ -1601,6 +1602,7 @@ def app_quit(self, action, param): | |||||
|
||||||
# log out of the system after clicking on the "Log Out" button | ||||||
def logout(self, action, param): | ||||||
print(self.win.environment) | ||||||
if snap: | ||||||
bus = dbus.SystemBus() | ||||||
manager = dbus.Interface(bus.get_object("org.freedesktop.login1", "/org/freedesktop/login1"), 'org.freedesktop.login1.Manager') | ||||||
|
@@ -1612,6 +1614,8 @@ def logout(self, action, param): | |||||
os.system("dbus-send --print-reply --session --dest=org.kde.LogoutPrompt /LogoutPrompt org.kde.LogoutPrompt.promptLogout") | ||||||
elif self.win.environment == 'COSMIC (New)': | ||||||
os.system("dbus-send --print-reply --session --dest=com.system76.CosmicSession --type=method_call /com/system76/CosmicSession com.system76.CosmicSession.Exit") | ||||||
elif self.win.environment == 'Hyprland': | ||||||
os.system("hyprctl dispatch exit") #does logout without prompting the user because i couldn't find a good way to do it | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Unfortunately I also don't know what D-Bus interface to use for Hyprland, so I've set it up so that if the application is running outside of Flatpak, the command is executed, if it's not, a notification is sent that you need to log out manually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i found a way to bypass the dbus and just kill the process but will need to test if it works it is with psutil os and signal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what i get is this {1: 'bwrap', 2: 'savedesktop'} is there a way to not sandbox the processes and find them via the program? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately i can not kill or send a dbus req to hyprland since it doesn't expose a port/bus so i think ill just look into how to remove that button when the wm is not found There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of importing the dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 'org.freedesktop.login1.Manager.TerminateSession' string:$(dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 'org.freedesktop.login1.Manager.ListSessions' | awk -F 'string "' '/string "/ {print $2; exit}' | awk -F '"' '{print $1}') however, it is necessary to add permissions to the Flatpak manifest in the finish-args section: |
||||||
else: | ||||||
os.system("gdbus call --session --dest org.gnome.SessionManager --object-path /org/gnome/SessionManager --method org.gnome.SessionManager.Logout 1") | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
home
variable is defined in thesrc/localization.py
file, so it is not necessary to use a new, same variable in this file. This is because Snap requires a custom home directory definition.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will remove that line thanks for the feedback on that one i did not know the localization.py did that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done