Xfce Forum

Sub domains
 

You are not logged in.

#1 2022-06-05 08:01:54

SpongB0B
Member
Registered: 2022-06-01
Posts: 16

easiest way to backup / restore Mousepad settings

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 big_smile

Offline

#2 2022-06-05 08:20:30

Tamaranch
Member
Registered: 2020-12-31
Posts: 267

Re: easiest way to backup / restore Mousepad settings

SpongB0B wrote:

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

#3 2022-06-05 08:44:05

Tamaranch
Member
Registered: 2020-12-31
Posts: 267

Re: easiest way to backup / restore Mousepad settings

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

#4 2022-06-07 04:47:07

SpongB0B
Member
Registered: 2022-06-01
Posts: 16

Re: easiest way to backup / restore Mousepad settings

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 smile


Linux noob, plz be kind big_smile

Offline

#5 2022-06-07 05:34:32

KBar
Moderator
Registered: 2021-11-05
Posts: 689

Re: easiest way to backup / restore Mousepad settings

SpongB0B wrote:

I'm starting to learn shell\bash scripting today if someone have good references I'm all ears smile

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! tongue

Offline

#6 2022-06-09 02:14:14

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: easiest way to backup / restore Mousepad settings

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

#7 2022-06-14 18:19:03

SpongB0B
Member
Registered: 2022-06-01
Posts: 16

Re: easiest way to backup / restore Mousepad settings

Thank you all for your inputs !

KBar wrote:

... 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

KBar wrote:

ShellCheck is a super handy tool to possess. Its command-line utility is available on most repositories.

Wooaa Seem a great tool ! thanks !

Skaperen wrote:

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... wink ) I need to test it under Linux smile if you have good links I'm all ears smile


Linux noob, plz be kind big_smile

Offline

#8 2022-06-14 22:58:03

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 812

Re: easiest way to backup / restore Mousepad settings

SpongB0B wrote:

I know well Python (Under Windows, no comment please, we all do mistake... wink ) I need to test it under Linux smile if you have good links I'm all ears smile

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

#9 2022-06-15 06:42:13

KBar
Moderator
Registered: 2021-11-05
Posts: 689

Re: easiest way to backup / restore Mousepad settings

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! tongue

Offline

Board footer

Powered by FluxBB