Skip to content
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

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4084f59
Update config.py added hyprland start
pyclicker Oct 26, 2024
3e9865b
Update config.py
pyclicker Oct 26, 2024
a3b174a
Update config.py
pyclicker Oct 26, 2024
2945011
second commit
Oct 27, 2024
3856bae
final commit?
Oct 27, 2024
24511a2
final?
Oct 27, 2024
3675dd6
last bugfix (fixed variable name)
Oct 27, 2024
a725806
still not stable and bugfixing
Oct 27, 2024
c93eb37
changed the os command to shutil.copytree
Oct 27, 2024
b48bd09
FINAL COMMIT FOR HYPRLAND UPDATE
Oct 27, 2024
2ae7d59
Merge branch 'vikdevelop:main' into master
pyclicker Oct 27, 2024
4b8f020
Update README.md
pyclicker Oct 27, 2024
3b30e77
deleted ".flatpak-builder" folder
Oct 27, 2024
f5b8860
removed commented out lines
Oct 27, 2024
147cc36
Update src/config.py
pyclicker Oct 28, 2024
c053578
i do not know what i changed but it changed
Oct 28, 2024
5ac2477
resolved the tab error
Oct 28, 2024
3cb3c9a
removed the lambda function for the config folder
Oct 28, 2024
caf50a8
Merge remote-tracking branch 'refs/remotes/origin/master'
Oct 28, 2024
efeb82d
i think install_native.sh will work now
Oct 28, 2024
12377fc
readded src/config.py
Oct 28, 2024
480c171
edits to src/config.py mainly removing a usely comment reindenting a …
Oct 28, 2024
f5af0c7
removed home = os.getenv('HOME')
Oct 28, 2024
35e74e7
(src/main_window.py) commented out and wrote "needs to be fixed but i…
Oct 28, 2024
d2c09d8
uncommented out something i commented out for no reason
Oct 28, 2024
cdfc16d
i forgot i removed the home import so i readded it
Oct 28, 2024
acc313e
plugged the github to issue a request for a feature and removed a use…
Oct 28, 2024
b475151
uncommented a line and rewrote a comment because it was very informal
Oct 28, 2024
a235dc6
added psutil
Oct 28, 2024
1c7048d
fix for hyprctl dispatch exit?
Oct 28, 2024
4bcd124
removed the plug
Oct 28, 2024
f40b173
not working but it can read processes although not the host processes
Oct 28, 2024
40832aa
did not remove the logout button but made it not pressable when on a …
Oct 28, 2024
673dbdc
removed the psutil dependency
Oct 28, 2024
4460041
added a comment about hyprland
Oct 28, 2024
e084d80
removed a few useless lines
Oct 28, 2024
307d410
i am unsure if the added line does anything but my obs stopped workin…
Oct 28, 2024
7fdf1ef
thought it was stable but forgot to remove dep
Oct 28, 2024
37c5018
Update src/main_window.py
pyclicker Oct 28, 2024
5417792
Update src/main_window.py
pyclicker Oct 28, 2024
ce8c4f4
logic to check if flatpak is active when running hyprland
pyclicker Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- MATE
- KDE Plasma
- Deepin
- Hyprland

### SaveDesktop can save:
- your icons, fonts, and themes
Expand Down Expand Up @@ -134,7 +135,10 @@ NOTE: It can happen that a backup file will not be created, in that case, just a
- ~/.config/deepin
- ~/.local/share/deepin
```

- **Hyprland**
```
- ~/.config/hypr
```
</details>

## Contributing
Expand Down
Empty file modified native/install_native.sh
100644 → 100755
Empty file.
28 changes: 18 additions & 10 deletions src/config.py
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')
Copy link
Owner

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 the src/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.

Copy link
Author

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#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':
Expand All @@ -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 *
Copy link
Owner

Choose a reason for hiding this comment

The 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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not know why i deleted that ......

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


class Save:
def __init__(self):
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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:
Copy link
Owner

@vikdevelop vikdevelop Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif environment == None:
elif environment == None:

This row is not aligned correctly, which generates a TabError.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

print("→ SKIPPING: SaveDesktop is running in the TTY mode")

if flatpak:
Expand Down
6 changes: 5 additions & 1 deletion src/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
os.system("hyprctl dispatch exit") #does logout without prompting the user because i couldn't find a good way to do it
os.system("hyprctl dispatch exit") if not flatpak else os.system(f'notify-send "{_["err_occured"]}" "It is not possible to log out of the system in the Flatpak environment. Please log out manually."')

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.

Copy link
Author

Choose a reason for hiding this comment

The 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

Copy link
Author

Choose a reason for hiding this comment

The 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?

Copy link
Author

@pyclicker pyclicker Oct 28, 2024

Choose a reason for hiding this comment

The 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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of importing the psutil and signal modules, you can use this command, which should hopefully work on all DEs (I tried it on GNOME, and it works):

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: --system-talk-name=org.freedesktop.login1.

else:
os.system("gdbus call --session --dest org.gnome.SessionManager --object-path /org/gnome/SessionManager --method org.gnome.SessionManager.Logout 1")

Expand Down