You are not logged in.
Hi everyone,
I would like to backup my XFCE mousepad apps settings and restore them from the same user or another one (share).
I can see all the settings with
gsettings list-recursively org.xfce.mousepad
I was thinking to export the output >> output.txt
Then create a shell\bash script that read the file line by line and do the following ~action
in Python it would look like
with open(output.txt) as readed:
for x in readed:
"gsettings set" & x
My Shell scripting are limited right now, but maybe there a simpler solution than a script ?
Thanks.
Linux noob, plz be kind
Offline
My Shell scripting are limited right now, but maybe there a simpler solution than a script ?
I don't think so.
gsettings doesn't have a restore option, but as you can see it's not difficult to do it yourself.
In shell it would look like this
while read schema key value; do
gsettings set "$schema" "$key" "$value"
done <output.txt
Offline
Note that, for technical reasons, plugin preferences are not listed in
gsettings list-recursively org.xfce.mousepad
It's the same for Gedit for example.
There is only one plugin that has preferences at the moment, so it's not a big deal, but in principle you have to do a little extra work to get them.
This extra command should recover everything:
gsettings list-schemas | grep -xE 'org\.xfce\.mousepad\.plugins\.[^.]+' | xargs gsettings list-recursively >>output.txt
Then the restoration can be done in one go.
Last edited by Tamaranch (2022-06-05 08:47:58)
Offline
Thank you very much @Tamaranch !
indeed in 3 lines of code it's settle. Thx for the extra post about the plugins !
I'm starting to learn shell\bash scripting today if someone have good references I'm all ears
Linux noob, plz be kind
Offline
I'm starting to learn shell\bash scripting today if someone have good references I'm all ears
The Linux Command Line by William Shotts is a must-read if you're a complete beginner.
Classic Shell Scripting is another brilliant book that covers almost everything about POSIX shell.
If portability is top priority, you'll want to follow the IEEE Std 1003.1™-2017 (also known as POSIX.1-2017).
Of course, there are coding standards for shell scripting as well; the Google one is referenced a lot.
ShellCheck is a super handy tool to possess. Its command-line utility is available on most repositories.
Even though POSIX shell is very bare-bones and restricted, its built-in utilities can do a lot of processing and work. For example, parameter expansion provides a very rudimentary substring processing. You may be tempted or accustomed to using tools like sed or the likes, but a simple expansion like:
printf "%s\n" "${string##*/}"
is much more efficient and cheaper.
PROGNAME="${0##*/}" # this simple expansion replaces the `basename` utility, thus avoiding an expensive exec call
Some say that shell scripts are inherently inefficient and are supposed to invoke other utilities to do the job. While that is true, extra care and efficiency never hurts. An advice like "Just learn a real programming language!" doesn't always apply because 1) writing shell scripts is way easier and allows for faster deployment; 2) what if I don't know anything about programming at all, let alone a programming language? Shell scripting, however "primitive" and "inefficient" it may appear, is still a very good introduction to programming and a nice skill to have.
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
as it turns out, some really great scripts have been written in bash that can do quite many things. OTOH, Python can push those boundaries and is quite easy to learn. or you can learn just enough Python to make your own tools for shell scripting.
Offline
Thank you all for your inputs !
... The Linux Command Line by William Shotts is a must-read if you're a complete beginner.
...
Thank you @KBar , I've started https://www.gnu.org/software/bash/manual/bash.html that is the reference once I finish this one I will look the one from William Shotts
ShellCheck is a super handy tool to possess. Its command-line utility is available on most repositories.
Wooaa Seem a great tool ! thanks !
as it turns out, some really great scripts have been written in bash that can do quite many things. OTOH, Python can push those boundaries and is quite easy to learn. or you can learn just enough Python to make your own tools for shell scripting.
I know well Python (Under Windows, no comment please, we all do mistake... ) I need to test it under Linux if you have good links I'm all ears
Linux noob, plz be kind
Offline
I know well Python (Under Windows, no comment please, we all do mistake... ) I need to test it under Linux if you have good links I'm all ears
if you have no Linux right now, you could run a virtual machine for Linux under Windows or run Linux with a virtual machine for Windows if you are willing to have no Window while getting Linux to run.
another option is to use a cloud service for little things. i use AWS.
or do you have a spare computer? Linux still works on smaller machines. i think Xubuntu 20.04 has a 32-bit version. 18.04 does.
Offline
Canonical dropped support for 32-bit releases years ago.
Remember to edit the subject of your topic to include the [SOLVED] tag once you're satisfied with the answers or have found a solution (in which case, don't forget to share it as well), so that other members of the community can quickly refer to it and save their time. Pretty please!
Offline
[ Generated in 0.014 seconds, 7 queries executed - Memory usage: 558.09 KiB (Peak: 574.94 KiB) ]