Skip to content

Commit

Permalink
Merge pull request #34 from Prayag2/dev
Browse files Browse the repository at this point in the history
Please read the changelog for more info.
  • Loading branch information
Prayag2 authored Apr 11, 2021
2 parents 1b56347 + b0f52c6 commit 1edc5a3
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MASTER]
disable=broad-except, too-many-locals
disable=broad-except, too-many-locals, too-many-branches
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]


## [2.0.0] - 2021-04-11
### Added
- Possibility to define multiple backup targets via the configuration file.
- Errors will be saved to `konsave_log.txt` in the home directory.
- Ability to use a few variables and functions in the configuration file.
- Ability to use Konsave on all desktop environments.

### Changed
- Improved export and import feature. You'll be able change which files to export and import from the configuration file.
- Changed yaml loader from `yaml.FullLoader` to `yaml.SafeLoader`
- The version will now be dynamically printed.

### Break
- The old configuration files and profiles won't work with this version of Konsave.

## [1.1.9] - 2021-03-18
### Fixes
Expand Down Expand Up @@ -116,6 +130,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- You can also import ".knsv" files as profiles!


[2.0.0]: https://github.com/Prayag2/konsave/compare/v1.1.9...v2.0.0
[1.1.9]: https://github.com/Prayag2/konsave/compare/v1.1.8...v1.1.9
[1.1.8]: https://github.com/Prayag2/konsave/compare/v1.1.7...v1.1.8
[1.1.7]: https://github.com/Prayag2/konsave/compare/v1.1.6...v1.1.7
Expand Down
81 changes: 75 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1 align=center> Konsave (Save Plasma Customization) </h1>
<p align=center>A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Also, it has a "K" in the name :D</p>
<h1 align=center> Konsave (Save Linux Customization) </h1>
<p align=center>A CLI program that will let you save and apply your Linux customizations with just one command! It officially supports KDE Plasma but it can be used on all other desktop environments too!</p>

---

Expand Down Expand Up @@ -36,11 +36,80 @@ You may need to log out and log in to see all the changes.
### Wipe all profiles
`konsave -w` or `konsave --wipe`

## Uninstall Konsave
To uninstall konsave, run the following:
`python -m pip uninstall konsave`
<br><hr><br>

## Contribution

## Editing the configuration file
You can make changes to Konsave's configuration file according to your needs. The configuration file is located in `~/.config/konsave/config.yaml`.
When using Konsave for the first time, you'll be prompted to enter your desktop environment.
For KDE Plasma users, the configuration file will be pre-configured.

### Format
The configuration file should be formatted in the following way:
```
---
save:
name:
location: "path/to/parent/directory"
entries:
# These are files to be backed up.
# They should be present in the specified location.
- file1
- file2
export:
# This includes files which will be exported with your profile.
# They will not be saved but only be exported and imported.
# These may include files like complete icon packs and themes..
name:
location: "path/to/parent/directory"
entries:
- file1
- file2
...
```

### Adding more files/folders to backup
You can add more files/folders in the configuration file like this:
```
save:
name:
location: "path/to/parent/directory"
entries:
- file1
- file2
- folder1
- folder2
export
anotherName:
location: "another/path/to/parent/directory"
entries:
- file1
- file2
- folder1
- folder2
```

### Using variables and functions
You can use a few variables and functions in the `location` of each entry in the configuration file. These are:
`$HOME`: points to the home directory
`$CONFIG_DIR`: points to `~/.config`
`$KONSAVE_DIR`: points to `~/.config/konsave`
`$PROFILES_DIR`: points to `~/.config/konsave/profiles`
`${ENDS_WITH="text"}`: for folders with different names on different computers whose names end with the same thing.
The best example for this is the ".default-release" folder in `~/.mozilla/firefox`.
`${BEGINS_WITH="text"}`: for folders with different names on different computers whose names start with the same thing.
Here's an example of how you can use these variables:
```
save:
firefox:
location: "$HOME/.mozilla/firefox/${ENDS_WITH='.default-release'}"
entries:
- chrome
```

<br><hr><br>

## Contributing
Please read [CONTRIBUTION.md](https://github.com/Prayag2/konsave/blob/master/CONTRIBUTION.md) for info about contributing.

## License
Expand Down
9 changes: 9 additions & 0 deletions konsave/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Top-level Konsave package."""

from pkg_resources import get_distribution, DistributionNotFound

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# Package is not installed
pass
32 changes: 30 additions & 2 deletions konsave/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Konsave entry point."""

import argparse
import os
import shutil
from pkg_resources import resource_filename
from konsave.funcs import (
list_profiles,
save_profile,
Expand All @@ -9,8 +12,14 @@
export,
import_profile,
wipe,
log,
)
from konsave.consts import (
VERSION,
CONFIG_FILE,
list_of_profiles,
length_of_lop,
)
from konsave.vars import VERSION, list_of_profiles, length_of_lop


def _get_parser() -> argparse.ArgumentParser:
Expand Down Expand Up @@ -90,13 +99,32 @@ def _get_parser() -> argparse.ArgumentParser:

def main():
"""The main function that handles all the arguments and options."""

if not os.path.exists(CONFIG_FILE):
log("Select your desktop environment-")
try:
desktop_environment = int(input("1. KDE Plasma\n2. Other\n=>"))
except ValueError:
log("Invalid input.")
return
else:
if desktop_environment == 1:
default_config_path = resource_filename("konsave", "conf_kde.yaml")
shutil.copy(default_config_path, CONFIG_FILE)
elif desktop_environment == 2:
default_config_path = resource_filename("konsave", "conf_other.yaml")
shutil.copy(default_config_path, CONFIG_FILE)
else:
log("Invalid input.")
return

parser = _get_parser()
args = parser.parse_args()

if args.list:
list_profiles(list_of_profiles, length_of_lop)
elif args.save:
save_profile(args.save, list_of_profiles, args.force)
save_profile(args.save, list_of_profiles, force=args.force)
elif args.remove:
remove_profile(args.remove, list_of_profiles, length_of_lop)
elif args.apply:
Expand Down
30 changes: 0 additions & 30 deletions konsave/conf.yaml

This file was deleted.

105 changes: 105 additions & 0 deletions konsave/conf_kde.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
# This is the configuration file for konsave. This file is pre-configured for KDE Plasma users.
# This will backup all the important files for your Plasma customizations.
# Please make sure it follows the correct format for proper working of konsave.
# The format should be:
# ---
# save:
# name:
# location: "path/to/parent/directory"
# entries:
# # these are files to be backed up. They should be present in the specified location.
# - file1
# - file2
# export:
# # This includes files which will be exported with your profile.
# # They will not be saved but only be exported and imported.
# # These may include files like complete icon packs and themes..
# name:
# location: "path/to/parent/directory"
# entries:
# - file1
# - file2
# ...
# You can use these variables and functions in the locations of different entries:
# $HOME: the home directory
# $PROFILES_DIR: directory where all profiles are saved
# $CONFIG_DIR: refers to "$HOME/.config/"
# $KONSAVE_DIR: the location where all Konsave files are stored ("$CONFIG_DIR/konsave").
# ${ENDS_WITH="text"}: for folders with different names on different computers whose names end with the same thing.
# The best example for this is the ".default-release" folder for firefox.
# ${BEGINS_WITH="text"}: for folders with different names on different computers whose names start with the same thing.

save:
configs:
location: "$HOME/.config"
entries:
- gtk-2.0
- gtk-3.0
- gtk-4.0
- Kvantum
- latte
- dolphinrc
- konsolerc
- kcminputrc
- kdeglobals
- kglobalshortcutsrc
- klipperrc
- krunnerrc
- kscreenlockerrc
- ksmserverrc
- kwinrc
- kwinrulesrc
- plasma-org.kde.plasma.desktop-appletsrc
- plasmarc
- plasmashellrc
- gtkrc
- gtkrc-2.0
- lattedockrc
- breezerc
- oxygenrc
- lightlyrc
- ksplashrc
- khotkeysrc

# Here are a few examples of how you can add more stuff to back up
# firefox:
# location: "$HOME/.mozilla/firefox/${ENDS_WITH='.default-release'}"
# entries:
# - chrome # for firefox customizations

# oss:
# location: "$HOME/.config/Code - OSS/User/"
# entries:
# - settings.json


# The following files will only be used for exporting and importing.
export:
share_folder:
location: "$HOME/.local/share"
entries:
- plasma
- kwin
- konsole
- fonts
- color-schemes
# Add icons only if necessary. They can take up to a few gigabytes of storage easily.
#- icons
home_folder:
location: "$HOME/"
entries:
- .fonts
- .themes
- .icons # this refers to the cursor pack and not the icon pack.


# You can add more files to export like this
# name:
# location: "path"
# entries:
# - file1
# - file2
# - folder1
# - folder2
...
Loading

0 comments on commit 1edc5a3

Please sign in to comment.