Compare commits
7 Commits
5922d989e0
...
1ab6f3e6f9
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ab6f3e6f9 | |||
| c779077be6 | |||
| ea470d4c92 | |||
| 6e9cbf3fa3 | |||
| 1ce33cf152 | |||
| 18c1070540 | |||
| 8834bca7fb |
94
bin/mypass
94
bin/mypass
@@ -1,94 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
PASS = '/usr/bin/pass'
|
|
||||||
|
|
||||||
def run(args):
|
|
||||||
return(subprocess.run(
|
|
||||||
args,
|
|
||||||
stdin=sys.stdin,
|
|
||||||
stdout=sys.stdout,
|
|
||||||
stderr=sys.stderr).returncode)
|
|
||||||
|
|
||||||
def get_stdout(args):
|
|
||||||
return(subprocess.run(
|
|
||||||
args,
|
|
||||||
stdout=subprocess.PIPE).stdout)
|
|
||||||
|
|
||||||
def extract_from_dict(d, k, last=None):
|
|
||||||
if '.' in k:
|
|
||||||
k1, k2 = k.split('.', 1)
|
|
||||||
try:
|
|
||||||
d1 = d[k1]
|
|
||||||
return extract_from_dict(d1, k2, last=k1)
|
|
||||||
except KeyError:
|
|
||||||
print("\"{}\" was not found in the data".format(k))
|
|
||||||
sys.exit(3)
|
|
||||||
else:
|
|
||||||
if not isinstance(d, dict):
|
|
||||||
print("element \"{}\" is not a dictionary".format(last))
|
|
||||||
sys.exit(3)
|
|
||||||
try:
|
|
||||||
return d[k]
|
|
||||||
except KeyError:
|
|
||||||
print("\"{}\" was not found in the data".format(k))
|
|
||||||
sys.exit(3)
|
|
||||||
|
|
||||||
|
|
||||||
def cmd_get(*args):
|
|
||||||
if len(args) == 1:
|
|
||||||
print(get_stdout(['pass', 'show', args[0]]).split(b'\n')[0].decode())
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if len(args) < 2:
|
|
||||||
print("what do you want to get?")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
# get the pass output
|
|
||||||
out = get_stdout(['pass', 'show', args[0]])
|
|
||||||
try:
|
|
||||||
data = list(yaml.safe_load_all(out))[-1]
|
|
||||||
except yaml.scanner.ScannerError as e:
|
|
||||||
print("invalid YAML data: {}".format(str(e)))
|
|
||||||
return 2
|
|
||||||
except IndexError:
|
|
||||||
print("invalid YAML data: no YAML document found")
|
|
||||||
return 2
|
|
||||||
|
|
||||||
if not isinstance(data, dict):
|
|
||||||
print("invalid YAML data, not a dict")
|
|
||||||
return 2
|
|
||||||
|
|
||||||
for element in args[1:]:
|
|
||||||
keydata = extract_from_dict(data, element)
|
|
||||||
if isinstance(keydata, list) or isinstance(keydata, dict):
|
|
||||||
print(yaml.safe_dump(keydata, default_flow_style=False).strip())
|
|
||||||
else:
|
|
||||||
print(keydata)
|
|
||||||
|
|
||||||
cmds = ['get']
|
|
||||||
git_push_commands = ['insert', 'edit', 'generate', 'rm', 'mv', 'cp']
|
|
||||||
|
|
||||||
def run_pass(argv):
|
|
||||||
return run([PASS] + argv[1:])
|
|
||||||
|
|
||||||
def just_call_pass(argv):
|
|
||||||
sys.exit(run_pass(argv))
|
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
|
||||||
just_call_pass(sys.argv)
|
|
||||||
elif sys.argv[1] not in cmds:
|
|
||||||
if sys.argv[1] not in git_push_commands:
|
|
||||||
just_call_pass(sys.argv)
|
|
||||||
else:
|
|
||||||
e = run_pass(sys.argv)
|
|
||||||
if e == 0:
|
|
||||||
print("Pushing to remote repository...")
|
|
||||||
run([PASS, 'git', 'push'])
|
|
||||||
print("Done")
|
|
||||||
sys.exit(e)
|
|
||||||
else:
|
|
||||||
sys.exit(globals()['cmd_' + sys.argv[1]](*sys.argv[2:]))
|
|
||||||
@@ -81,7 +81,7 @@ packages:
|
|||||||
pinta:
|
pinta:
|
||||||
archlinux: ["pinta"]
|
archlinux: ["pinta"]
|
||||||
pass:
|
pass:
|
||||||
archlinux: ["pass", "passff-host"]
|
archlinux: ["pass", "passff-host", "xclip"]
|
||||||
urxvt:
|
urxvt:
|
||||||
archlinux: ["rxvt-unicode"]
|
archlinux: ["rxvt-unicode"]
|
||||||
alacritty:
|
alacritty:
|
||||||
@@ -247,7 +247,7 @@ packages:
|
|||||||
mpv:
|
mpv:
|
||||||
archlinux: ["mpv"]
|
archlinux: ["mpv"]
|
||||||
gnome-keyring:
|
gnome-keyring:
|
||||||
archlinux: ["gnome-keyring"]
|
archlinux: ["gnome-keyring", "seahorse"]
|
||||||
element:
|
element:
|
||||||
archlinux: ["element-desktop"]
|
archlinux: ["element-desktop"]
|
||||||
maim:
|
maim:
|
||||||
|
|||||||
68
user.yml
68
user.yml
@@ -271,43 +271,25 @@
|
|||||||
- ~/.local/share/nvim/
|
- ~/.local/share/nvim/
|
||||||
- ~/.local/share/nvim/site/
|
- ~/.local/share/nvim/site/
|
||||||
- ~/.local/share/nvim/site/autoload/
|
- ~/.local/share/nvim/site/autoload/
|
||||||
- ~/.vim/
|
|
||||||
- ~/.vim/autoload
|
|
||||||
|
|
||||||
- name: install vim-plug
|
- name: install vim-plug
|
||||||
copy:
|
copy:
|
||||||
src: contrib/vim-plug/plug.vim
|
src: contrib/vim-plug/plug.vim
|
||||||
dest: ~/.vim/autoload/plug.vim
|
dest: ~/.local/share/nvim/site/autoload/plug.vim
|
||||||
owner: "{{ user.name }}"
|
owner: "{{ user.name }}"
|
||||||
group: "{{ user_group_name }}"
|
group: "{{ user_group_name }}"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
- name: symlink vim-plug for neovim
|
|
||||||
file:
|
|
||||||
state: link
|
|
||||||
path: ~/.local/share/nvim/site/autoload/plug.vim
|
|
||||||
src: ~/.vim/autoload/plug.vim
|
|
||||||
force: true
|
|
||||||
|
|
||||||
- name: install vim plugins
|
- name: install vim plugins
|
||||||
command: sh -c 'PATH=/usr/local/go/bin:$PATH GOROOT=/usr/local/go GOPATH=/home/{{ user.name }}/.go /usr/bin/nvim --headless +PlugInstall +qall'
|
command: nvim --headless +PlugInstall +qall
|
||||||
register: vim_plugin_install
|
register: vim_plugin_install
|
||||||
changed_when: vim_plugin_install.stderr != ""
|
changed_when: vim_plugin_install.stderr != ""
|
||||||
|
|
||||||
- name: install go binaries for vim
|
|
||||||
command: sh -c 'PATH=/usr/local/go/bin:$PATH GOROOT=/usr/local/go GOPATH=/home/{{ user.name }}/.go /usr/bin/nvim --headless +GoInstallBinaries +qall'
|
|
||||||
changed_when: false
|
|
||||||
|
|
||||||
- name: update vim plugins
|
- name: update vim plugins
|
||||||
command: sh -c 'PATH=/usr/local/go/bin:$PATH GOROOT=/usr/local/go GOPATH=/home/{{ user.name }}/.go /usr/bin/nvim --headless +PlugUpdate +qall'
|
command: nvim --headless +PlugUpdate +qall
|
||||||
register: vim_plugin_update
|
register: vim_plugin_update
|
||||||
changed_when: vim_plugin_update.stderr != ""
|
changed_when: vim_plugin_update.stderr != ""
|
||||||
tags: [user-update]
|
|
||||||
|
|
||||||
- name: update go binaries for vim
|
|
||||||
command: sh -c 'PATH=/usr/local/go/bin:$PATH GOROOT=/usr/local/go GOPATH=/home/{{ user.name }}/.go /usr/bin/nvim --headless +GoUpdateBinaries +qall'
|
|
||||||
changed_when: false
|
|
||||||
tags: [user-update]
|
|
||||||
tags: [vim-plugins]
|
tags: [vim-plugins]
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
@@ -374,45 +356,6 @@
|
|||||||
loop: "{{ user.firefox_profiles | dict2items }}"
|
loop: "{{ user.firefox_profiles | dict2items }}"
|
||||||
when: not ansible_check_mode
|
when: not ansible_check_mode
|
||||||
|
|
||||||
- name: firefox - create target directory for passff
|
|
||||||
file:
|
|
||||||
path: ~/.mozilla/native-messaging-hosts
|
|
||||||
owner: "{{ user.name }}"
|
|
||||||
group: "{{ user_group_name }}"
|
|
||||||
state: directory
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: check if host application file already exists
|
|
||||||
stat:
|
|
||||||
path: ~/.mozilla/native-messaging-hosts/{{ item.name }}
|
|
||||||
register: passff_file
|
|
||||||
loop:
|
|
||||||
- name: passff.json
|
|
||||||
- name: passff.py
|
|
||||||
|
|
||||||
- name: firefox - get passff host application
|
|
||||||
get_url:
|
|
||||||
url: https://github.com/passff/passff-host/releases/download/1.2.2/{{ item.name }}
|
|
||||||
dest: ~/.mozilla/native-messaging-hosts/{{ item.name }}
|
|
||||||
owner: "{{ user.name }}"
|
|
||||||
group: "{{ user_group_name }}"
|
|
||||||
mode: "{{ item.mode }}"
|
|
||||||
force: false
|
|
||||||
when: not (passff_file.results | selectattr('item.name', 'eq', item.name) | list)[0].stat.exists
|
|
||||||
loop:
|
|
||||||
- name: passff.json
|
|
||||||
mode: '0644'
|
|
||||||
- name: passff.py
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: firefox - configure path to passff
|
|
||||||
lineinfile:
|
|
||||||
path: ~/.mozilla/native-messaging-hosts/passff.json
|
|
||||||
regexp: '"path": ".*"'
|
|
||||||
line: " \"path\": \"{{ path }}\","
|
|
||||||
vars:
|
|
||||||
path: "/home/{{ user.name }}/.mozilla/native-messaging-hosts/passff.py"
|
|
||||||
|
|
||||||
- name: firefox - create chrome directory
|
- name: firefox - create chrome directory
|
||||||
file:
|
file:
|
||||||
path: "{{ item.profile_path }}/chrome/"
|
path: "{{ item.profile_path }}/chrome/"
|
||||||
@@ -434,9 +377,6 @@
|
|||||||
#sidebar-header {
|
#sidebar-header {
|
||||||
visibility: collapse !important;
|
visibility: collapse !important;
|
||||||
}
|
}
|
||||||
#sidebar {
|
|
||||||
width: 400px !important;
|
|
||||||
}
|
|
||||||
when:
|
when:
|
||||||
- not ansible_check_mode
|
- not ansible_check_mode
|
||||||
- user.firefox_profiles[item.profile_name].manage_css is sameas True
|
- user.firefox_profiles[item.profile_name].manage_css is sameas True
|
||||||
@@ -589,6 +529,6 @@
|
|||||||
printf '%s\n' 'Done'
|
printf '%s\n' 'Done'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec mypass "${@}"
|
command -p pass "${@}"
|
||||||
when: user.enable_passwordstore|default(false) is sameas true
|
when: user.enable_passwordstore|default(false) is sameas true
|
||||||
tags: [passwordstore]
|
tags: [passwordstore]
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ export BROWSER="firefox"
|
|||||||
export PAGER="less"
|
export PAGER="less"
|
||||||
export LESS="FRX"
|
export LESS="FRX"
|
||||||
|
|
||||||
export VIMRC="$HOME/.vimrc"
|
|
||||||
|
|
||||||
export WINEPATH="$HOME/games/wine"
|
export WINEPATH="$HOME/games/wine"
|
||||||
|
|
||||||
export LOGDIR="$HOME/.var/log"
|
export LOGDIR="$HOME/.var/log"
|
||||||
|
|||||||
Reference in New Issue
Block a user