jistr / ansible-gsetting

Ansible module for setting GSettings entries
Apache License 2.0
47 stars 18 forks source link

Setting key fails when fish shell is user's default shell #5

Open radomirbosak opened 7 years ago

radomirbosak commented 7 years ago

When I try to run task like this:

- name: new termnial shortcut
  gsetting:
    user: me
    key: "org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/.name"
    value: "New terminal"

I get this error:

TASK [gnome : apply new term] ************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Password: su: Authentication failure\nTraceback (most recent call last):\n  File \"/tmp/ansible_g501K0/ansible_module_gsetting.py\", line 81, in <module>\n    main()\n  File \"/tmp/ansible_g501K0/ansible_module_gsetting.py\", line 68, in main\n    old_value = _get_value(user, key)\n  File \"/tmp/ansible_g501K0/ansible_module_gsetting.py\", line 47, in _get_value\n    'su', '-', user , '-c', command\n  File \"/usr/lib64/python2.7/subprocess.py\", line 219, in check_output\n    raise CalledProcessError(retcode, cmd, output=output)\nsubprocess.CalledProcessError: Command '['su', '-', 'me', '-c', 'export `/usr/bin/dbus-launch` ; /usr/bin/gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name ; kill $DBUS_SESSION_BUS_PID &> /dev/null']' returned non-zero exit status 1\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}

The important part is this:

subprocess.CalledProcessError:
Command 
'['su', '-', 'me', '-c', 'export `/usr/bin/dbus-launch` ;
/usr/bin/gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name ;
kill $DBUS_SESSION_BUS_PID &> /dev/null']' returned non-zero exit status 1

and this is because fish shell doesn't support backticks (they come up in export `/usr/bin/dbus-launch`)

Yannik commented 6 years ago

does export $(/usr/bin/dbus-launch) work with your shell?

mrmeszaros commented 6 years ago

@Yannik fish is not compatible with other common shells (bash,zsh,ksh, etc.)