Thanks to python-gnomekeyring, this is relatively easy:
python -c "import gnomekeyring;gnomekeyring.unlock_sync(None, 'my password');"
Or as a proper script:
#!/usr/bin/env python
import gnomekeyring
gnomekeyring.unlock_sync(None, 'my password');
I think you don't need to install the package. But it can't hurt to try.
Keep in mind that storing your password on your hard disk is an immense security risk. You should be using this instead:
#!/usr/bin/env python
import gnomekeyring
import getpass
gnomekeyring.unlock_sync(None, getpass.getpass('Password: '));
You can save this script, for example, as unlock-keyring.py
and then do the following:
sudo mv unlock-keyring.py /usr/bin/unlock-keyring
sudo chmod a+x /usr/bin/unlock-keyring
From then, you can always just type unlock-keyring
and be prompted for a password. Don't do this with the version that contains your password.
You can replace None
with the name of your keyring, e.g. 'session'
, if you want to unlock one that isn't the default.
I'm having a hard time testing this properly, so please let me know if it doesn't work and I'll take a look at it right away. Also let me know if it does work :-)
Solution to your problem
The right solution here is to omit calling gnome-terminal
and bash
and even setting an unneeded variable in the first place, all of that is not needed in your case:
mpv -- "$(yad --entry)"
I added quotes to handle the URL correctly, this ensures it can contain e.g. whitespaces and ampersand signs (&
) and the command still works. --
tells mpv
to stop looking for options and treats whatever you choose to give it as an argument instead. Image the common case where you have a file named --version
in the directory you start mpv from and just enter this filename, how can mpv
know whether to show you its version string or open the file?
Answer to your question
nohup
or disown
can be used to detach a process from the shell that started it, see Differences between "<command> & disown" and "nohup <command> & disown".
In your case the correct solution would be:
gnome-terminal -e nohup mpv -- "$(yad --entry)"
However for a much better solution see above.
Best Answer
From wikipedia: