Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 (logout no worky so do not make a issue)

### 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
18 changes: 11 additions & 7 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
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
#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
#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,6 +32,8 @@
environment = 'KDE Plasma'
elif os.getenv('XDG_CURRENT_DESKTOP') == 'Deepin':
environment = 'Deepin'
elif os.getenv('XDG_CURRENT_DESKTOP') == 'Hyprland':
environment = 'Hyprland'
else:
from tty_environments import *

Expand Down Expand Up @@ -76,7 +76,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 +136,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,6 +250,8 @@ 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 == 'Hyprland':
os.system(f"cp -aur ./hypr {home}/.config/ -v")
elif environment == None:
print("→ SKIPPING: SaveDesktop is running in the TTY mode")

Expand Down
2 changes: 2 additions & 0 deletions src/localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
# Setting home as per the confinement
home = snap_real_home if 'SNAP' in os.environ else snap_home

# Setting Desktop variable
desktopenv = os.getenv("XDG_CURRENT_DESKTOP")
# Load GSettings database
settings = Gio.Settings.new_with_path("io.github.vikdevelop.SaveDesktop", "/io/github/vikdevelop/SaveDesktop/")

Expand Down
53 changes: 27 additions & 26 deletions src/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
from pathlib import Path
from threading import Thread
from gi.repository import Gtk, Adw, Gio, GLib
from localization import _, home, download_dir
from localization import _, home, download_dir, desktopenv, flatpak
from open_wiki import *
from shortcuts_window import *

# Application window
class MainWindow(Adw.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_title("SaveDesktop")
self.application = kwargs.get('application')

# header bar and toolbarview
self.headerbar = Adw.HeaderBar.new()
self.toolbarview = Adw.ToolbarView.new()
Expand All @@ -31,7 +30,23 @@ def __init__(self, *args, **kwargs):
# set the window size and maximization from the GSettings database
(width, height) = settings["window-size"]
self.set_default_size(width, height)


# Check the user's current desktop
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
# Check the user's current desktop
# Check the user's current desktop
desktopenv = os.getenv('XDG_CURRENT_DESKTOP')

desktop_map = {
'GNOME': 'GNOME',
'zorin:GNOME': 'GNOME',
'ubuntu:GNOME': 'GNOME',
'pop:GNOME': 'COSMIC (Old)',
'COSMIC': 'COSMIC (New)',
'Pantheon': 'Pantheon',
'X-Cinnamon': 'Cinnamon',
'Budgie:GNOME': 'Budgie',
'XFCE': 'Xfce',
'MATE': 'MATE',
'KDE': 'KDE Plasma',
'Deepin': 'Deepin',
'Hyprland': 'Hyprland'}

# if value is TRUE, it enables window maximalization
if settings["maximized"]:
self.maximize()
Expand Down Expand Up @@ -104,33 +119,16 @@ def __init__(self, *args, **kwargs):
self.toast = Adw.Toast.new(title='')
self.toast.set_timeout(0)

# Check the user's current desktop
desktop_env = os.getenv('XDG_CURRENT_DESKTOP')
desktop_map = {
'GNOME': 'GNOME',
'zorin:GNOME': 'GNOME',
'ubuntu:GNOME': 'GNOME',
'pop:GNOME': 'COSMIC (Old)',
'COSMIC': 'COSMIC (New)',
'Pantheon': 'Pantheon',
'X-Cinnamon': 'Cinnamon',
'Budgie:GNOME': 'Budgie',
'XFCE': 'Xfce',
'MATE': 'MATE',
'KDE': 'KDE Plasma',
'Deepin': 'Deepin'
}

# If the user has a supported environment, it shows the app window, otherwise, it shows the window with information about an unsupported environment
# If the user has a supported environment, it shows the app window, otherwise, it shows the window with information about an unsupported environment
def setup_environment(env_name):
self.environment = env_name
self.save_desktop()
self.import_desktop()
self.sync_desktop()
self.connect("close-request", self.on_close)

if desktop_env in desktop_map:
setup_environment(desktop_map[desktop_env])
if desktopenv in desktop_map:
setup_environment(desktop_map[desktopenv])
else:
# Handle unsupported desktop environments
self.toolbarview.add_top_bar(self.errHeaderbar)
Expand Down Expand Up @@ -1488,7 +1486,7 @@ def back_to_main(w):
active_window = app.get_active_window()
if active_window is None or not active_window.is_active():
app.send_notification(None, self.notification_import)

# stop spinner animation
self.importwaitSpinner.stop()
self.importwaitBox.remove(self.importwaitButton)
Expand Down Expand Up @@ -1567,7 +1565,8 @@ def __init__(self, **kwargs):
self.create_action('m_sync_with_key', self.sync_pc, ["<primary>s"] if settings["manually-sync"] else None)
self.create_action('quit', self.app_quit, ["<primary>q"])
self.create_action('shortcuts', self.shortcuts, ["<primary>question"])
self.create_action('logout', self.logout)
if not (flatpak and self.win.environment('Hyprland')):
self.create_action('logout', self.logout)
self.create_action('open_dir', self.open_dir)
self.connect('activate', self.on_activate)

Expand Down Expand Up @@ -1612,6 +1611,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 (not flatpak) and self.win.environment == 'Hyprland':
os.system("hyprctl dispatch exit")
Copy link
Owner

Choose a reason for hiding this comment

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

Unfortunately, the hyprctl command doesn't work in Flatpak, so you probably need to use dbus to log out the system, or use other options.

Copy link
Author

Choose a reason for hiding this comment

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

oh thanks for the feedback i will do that one later because i do not know how to kill hyprland or logout hyprland with a systemcall

Copy link
Author

Choose a reason for hiding this comment

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

commented out and wrote "needs to be fixed but i do not know how to make this call on flatpak via python"

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

Expand Down