set dconf-editor values programatically

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite












Is there a way that I can access and edit dconf-editor values programatically, I mean using phython or bash?



I want to develop a simple tool to edit some window management shortcuts. I know there are tools like compiz which provides this already, but need to have something quick and simple to work best with my requirements.



I there some sort of a API for dconf-editor? or an API for window management keyboard short cuts in general.



Basically I want to edit Switch Windows shortcuts (Alt + Tab) from bash or some other scripting language, i.e, without using a GUI.



Please advice.







share|improve this question

















  • 2




    I don't know about APIs but did you look at gsettings? For the window manager, you may need to be specific about what you intend doing.
    – DK Bose
    yesterday










  • I want to set switch window short cuts using bash or python, i know those can be edited from compiz, dconf-editor, etc. I want to do it from bash or some programming language
    – Bmax
    yesterday






  • 1




    from gi.repository import Gio :)
    – Rinzwind
    yesterday










  • As well as gsettings, there is a dconf command-line tool that you can use directly from the shell - see What is dconf, what is its function, and how do I use it?
    – steeldriver
    yesterday










  • Repeat question askubuntu.com/questions/755020/…
    – pauljohn32
    yesterday
















up vote
0
down vote

favorite












Is there a way that I can access and edit dconf-editor values programatically, I mean using phython or bash?



I want to develop a simple tool to edit some window management shortcuts. I know there are tools like compiz which provides this already, but need to have something quick and simple to work best with my requirements.



I there some sort of a API for dconf-editor? or an API for window management keyboard short cuts in general.



Basically I want to edit Switch Windows shortcuts (Alt + Tab) from bash or some other scripting language, i.e, without using a GUI.



Please advice.







share|improve this question

















  • 2




    I don't know about APIs but did you look at gsettings? For the window manager, you may need to be specific about what you intend doing.
    – DK Bose
    yesterday










  • I want to set switch window short cuts using bash or python, i know those can be edited from compiz, dconf-editor, etc. I want to do it from bash or some programming language
    – Bmax
    yesterday






  • 1




    from gi.repository import Gio :)
    – Rinzwind
    yesterday










  • As well as gsettings, there is a dconf command-line tool that you can use directly from the shell - see What is dconf, what is its function, and how do I use it?
    – steeldriver
    yesterday










  • Repeat question askubuntu.com/questions/755020/…
    – pauljohn32
    yesterday












up vote
0
down vote

favorite









up vote
0
down vote

favorite











Is there a way that I can access and edit dconf-editor values programatically, I mean using phython or bash?



I want to develop a simple tool to edit some window management shortcuts. I know there are tools like compiz which provides this already, but need to have something quick and simple to work best with my requirements.



I there some sort of a API for dconf-editor? or an API for window management keyboard short cuts in general.



Basically I want to edit Switch Windows shortcuts (Alt + Tab) from bash or some other scripting language, i.e, without using a GUI.



Please advice.







share|improve this question













Is there a way that I can access and edit dconf-editor values programatically, I mean using phython or bash?



I want to develop a simple tool to edit some window management shortcuts. I know there are tools like compiz which provides this already, but need to have something quick and simple to work best with my requirements.



I there some sort of a API for dconf-editor? or an API for window management keyboard short cuts in general.



Basically I want to edit Switch Windows shortcuts (Alt + Tab) from bash or some other scripting language, i.e, without using a GUI.



Please advice.









share|improve this question












share|improve this question




share|improve this question








edited yesterday
























asked 2 days ago









Bmax

1314




1314







  • 2




    I don't know about APIs but did you look at gsettings? For the window manager, you may need to be specific about what you intend doing.
    – DK Bose
    yesterday










  • I want to set switch window short cuts using bash or python, i know those can be edited from compiz, dconf-editor, etc. I want to do it from bash or some programming language
    – Bmax
    yesterday






  • 1




    from gi.repository import Gio :)
    – Rinzwind
    yesterday










  • As well as gsettings, there is a dconf command-line tool that you can use directly from the shell - see What is dconf, what is its function, and how do I use it?
    – steeldriver
    yesterday










  • Repeat question askubuntu.com/questions/755020/…
    – pauljohn32
    yesterday












  • 2




    I don't know about APIs but did you look at gsettings? For the window manager, you may need to be specific about what you intend doing.
    – DK Bose
    yesterday










  • I want to set switch window short cuts using bash or python, i know those can be edited from compiz, dconf-editor, etc. I want to do it from bash or some programming language
    – Bmax
    yesterday






  • 1




    from gi.repository import Gio :)
    – Rinzwind
    yesterday










  • As well as gsettings, there is a dconf command-line tool that you can use directly from the shell - see What is dconf, what is its function, and how do I use it?
    – steeldriver
    yesterday










  • Repeat question askubuntu.com/questions/755020/…
    – pauljohn32
    yesterday







2




2




I don't know about APIs but did you look at gsettings? For the window manager, you may need to be specific about what you intend doing.
– DK Bose
yesterday




I don't know about APIs but did you look at gsettings? For the window manager, you may need to be specific about what you intend doing.
– DK Bose
yesterday












I want to set switch window short cuts using bash or python, i know those can be edited from compiz, dconf-editor, etc. I want to do it from bash or some programming language
– Bmax
yesterday




I want to set switch window short cuts using bash or python, i know those can be edited from compiz, dconf-editor, etc. I want to do it from bash or some programming language
– Bmax
yesterday




1




1




from gi.repository import Gio :)
– Rinzwind
yesterday




from gi.repository import Gio :)
– Rinzwind
yesterday












As well as gsettings, there is a dconf command-line tool that you can use directly from the shell - see What is dconf, what is its function, and how do I use it?
– steeldriver
yesterday




As well as gsettings, there is a dconf command-line tool that you can use directly from the shell - see What is dconf, what is its function, and how do I use it?
– steeldriver
yesterday












Repeat question askubuntu.com/questions/755020/…
– pauljohn32
yesterday




Repeat question askubuntu.com/questions/755020/…
– pauljohn32
yesterday










1 Answer
1






active

oldest

votes

















up vote
0
down vote













For Python, use Gio module. Specifically, here's an example of two functions I use in my own code (feel free to see how they're used within my Launcher List Indicator):



from gi.repository import Gio

# Define your own class here

# Note that these use `self` for use with classes
# this could be removed otherwise

def gsettings_get(self, schema, path, key):
"""Get value of gsettings schema"""
if path is None:
gsettings = Gio.Settings.new(schema)
else:
gsettings = Gio.Settings.new_with_path(schema, path)
return gsettings.get_value(key)

def gsettings_set(self, schema, path, key, value):
"""Set value of gsettings schema"""
if path is None:
gsettings = Gio.Settings.new(schema)
else:
gsettings = Gio.Settings.new_with_path(schema, path)
if isinstance(value, list):
return gsettings.set_strv(key, value)
if isinstance(value, int):
return gsettings.set_int(key, value)


These functions make getting and setting values easy and similar to the command-line utilities; schema, path, and key values are all strings. For instance, to set Unity launcher position to "Bottom" you would do:



self.gsettings_set( 'com.canonical.Unity.Launcher', 'launcher-position', 'Bottom')


For shell scripts, there are dconf and gsettings command-line tools, the later being a front-end to dconf. The gsettings command is preferred because it performs safety checks on the input values. Example of usage:



 gsettings set com.canonical.Unity.Launcher launcher-position 'Bottom'


You can call these two from python using subprocess.call() or subprocess.check_output(), but this has the overhead of spawning extra process, which is unnecessary (And if you're going to do it Pythonic way, do it right via the API).



See also



  • Do GUI based application execute shell commands in the background?





share|improve this answer























    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1062197%2fset-dconf-editor-values-programatically%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    For Python, use Gio module. Specifically, here's an example of two functions I use in my own code (feel free to see how they're used within my Launcher List Indicator):



    from gi.repository import Gio

    # Define your own class here

    # Note that these use `self` for use with classes
    # this could be removed otherwise

    def gsettings_get(self, schema, path, key):
    """Get value of gsettings schema"""
    if path is None:
    gsettings = Gio.Settings.new(schema)
    else:
    gsettings = Gio.Settings.new_with_path(schema, path)
    return gsettings.get_value(key)

    def gsettings_set(self, schema, path, key, value):
    """Set value of gsettings schema"""
    if path is None:
    gsettings = Gio.Settings.new(schema)
    else:
    gsettings = Gio.Settings.new_with_path(schema, path)
    if isinstance(value, list):
    return gsettings.set_strv(key, value)
    if isinstance(value, int):
    return gsettings.set_int(key, value)


    These functions make getting and setting values easy and similar to the command-line utilities; schema, path, and key values are all strings. For instance, to set Unity launcher position to "Bottom" you would do:



    self.gsettings_set( 'com.canonical.Unity.Launcher', 'launcher-position', 'Bottom')


    For shell scripts, there are dconf and gsettings command-line tools, the later being a front-end to dconf. The gsettings command is preferred because it performs safety checks on the input values. Example of usage:



     gsettings set com.canonical.Unity.Launcher launcher-position 'Bottom'


    You can call these two from python using subprocess.call() or subprocess.check_output(), but this has the overhead of spawning extra process, which is unnecessary (And if you're going to do it Pythonic way, do it right via the API).



    See also



    • Do GUI based application execute shell commands in the background?





    share|improve this answer



























      up vote
      0
      down vote













      For Python, use Gio module. Specifically, here's an example of two functions I use in my own code (feel free to see how they're used within my Launcher List Indicator):



      from gi.repository import Gio

      # Define your own class here

      # Note that these use `self` for use with classes
      # this could be removed otherwise

      def gsettings_get(self, schema, path, key):
      """Get value of gsettings schema"""
      if path is None:
      gsettings = Gio.Settings.new(schema)
      else:
      gsettings = Gio.Settings.new_with_path(schema, path)
      return gsettings.get_value(key)

      def gsettings_set(self, schema, path, key, value):
      """Set value of gsettings schema"""
      if path is None:
      gsettings = Gio.Settings.new(schema)
      else:
      gsettings = Gio.Settings.new_with_path(schema, path)
      if isinstance(value, list):
      return gsettings.set_strv(key, value)
      if isinstance(value, int):
      return gsettings.set_int(key, value)


      These functions make getting and setting values easy and similar to the command-line utilities; schema, path, and key values are all strings. For instance, to set Unity launcher position to "Bottom" you would do:



      self.gsettings_set( 'com.canonical.Unity.Launcher', 'launcher-position', 'Bottom')


      For shell scripts, there are dconf and gsettings command-line tools, the later being a front-end to dconf. The gsettings command is preferred because it performs safety checks on the input values. Example of usage:



       gsettings set com.canonical.Unity.Launcher launcher-position 'Bottom'


      You can call these two from python using subprocess.call() or subprocess.check_output(), but this has the overhead of spawning extra process, which is unnecessary (And if you're going to do it Pythonic way, do it right via the API).



      See also



      • Do GUI based application execute shell commands in the background?





      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        For Python, use Gio module. Specifically, here's an example of two functions I use in my own code (feel free to see how they're used within my Launcher List Indicator):



        from gi.repository import Gio

        # Define your own class here

        # Note that these use `self` for use with classes
        # this could be removed otherwise

        def gsettings_get(self, schema, path, key):
        """Get value of gsettings schema"""
        if path is None:
        gsettings = Gio.Settings.new(schema)
        else:
        gsettings = Gio.Settings.new_with_path(schema, path)
        return gsettings.get_value(key)

        def gsettings_set(self, schema, path, key, value):
        """Set value of gsettings schema"""
        if path is None:
        gsettings = Gio.Settings.new(schema)
        else:
        gsettings = Gio.Settings.new_with_path(schema, path)
        if isinstance(value, list):
        return gsettings.set_strv(key, value)
        if isinstance(value, int):
        return gsettings.set_int(key, value)


        These functions make getting and setting values easy and similar to the command-line utilities; schema, path, and key values are all strings. For instance, to set Unity launcher position to "Bottom" you would do:



        self.gsettings_set( 'com.canonical.Unity.Launcher', 'launcher-position', 'Bottom')


        For shell scripts, there are dconf and gsettings command-line tools, the later being a front-end to dconf. The gsettings command is preferred because it performs safety checks on the input values. Example of usage:



         gsettings set com.canonical.Unity.Launcher launcher-position 'Bottom'


        You can call these two from python using subprocess.call() or subprocess.check_output(), but this has the overhead of spawning extra process, which is unnecessary (And if you're going to do it Pythonic way, do it right via the API).



        See also



        • Do GUI based application execute shell commands in the background?





        share|improve this answer















        For Python, use Gio module. Specifically, here's an example of two functions I use in my own code (feel free to see how they're used within my Launcher List Indicator):



        from gi.repository import Gio

        # Define your own class here

        # Note that these use `self` for use with classes
        # this could be removed otherwise

        def gsettings_get(self, schema, path, key):
        """Get value of gsettings schema"""
        if path is None:
        gsettings = Gio.Settings.new(schema)
        else:
        gsettings = Gio.Settings.new_with_path(schema, path)
        return gsettings.get_value(key)

        def gsettings_set(self, schema, path, key, value):
        """Set value of gsettings schema"""
        if path is None:
        gsettings = Gio.Settings.new(schema)
        else:
        gsettings = Gio.Settings.new_with_path(schema, path)
        if isinstance(value, list):
        return gsettings.set_strv(key, value)
        if isinstance(value, int):
        return gsettings.set_int(key, value)


        These functions make getting and setting values easy and similar to the command-line utilities; schema, path, and key values are all strings. For instance, to set Unity launcher position to "Bottom" you would do:



        self.gsettings_set( 'com.canonical.Unity.Launcher', 'launcher-position', 'Bottom')


        For shell scripts, there are dconf and gsettings command-line tools, the later being a front-end to dconf. The gsettings command is preferred because it performs safety checks on the input values. Example of usage:



         gsettings set com.canonical.Unity.Launcher launcher-position 'Bottom'


        You can call these two from python using subprocess.call() or subprocess.check_output(), but this has the overhead of spawning extra process, which is unnecessary (And if you're going to do it Pythonic way, do it right via the API).



        See also



        • Do GUI based application execute shell commands in the background?






        share|improve this answer















        share|improve this answer



        share|improve this answer








        edited 9 hours ago


























        answered 9 hours ago









        Sergiy Kolodyazhnyy

        63.3k9127270




        63.3k9127270






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1062197%2fset-dconf-editor-values-programatically%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Which professions warranted travel in Medieval times?

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error