Compare commits

...

18 Commits

Author SHA1 Message Date
54f135e316 bin: Add helper to get terraform target list from files 2020-10-05 22:06:58 +02:00
2163292379 bin: Add script to select pulse sink/source via rofi 2020-10-05 22:06:37 +02:00
c6bd162e20 shell: Add shortcut function to get k8s pod 2020-10-05 22:05:58 +02:00
4e37eaf90f shell: Auto-color diffs 2020-10-05 22:05:25 +02:00
1828707ecd Add install of kubectl 2020-10-05 22:05:02 +02:00
f07e4d368a Add install of Portfolio Performance 2020-10-05 22:04:53 +02:00
fed5e05266 dotfiles: Ensure target directory exists 2020-10-05 22:04:19 +02:00
306ce96780 tmux: Add continuum plugin 2020-10-05 22:03:24 +02:00
07e17fc56f Add removal list of installed packages 2020-10-05 22:03:05 +02:00
38f5a437e0 packages: Replace mousepad with pluma 2020-10-05 22:02:42 +02:00
a328e7dfdb i3: Add volume/mic toggle clicks in bar 2020-10-05 22:02:13 +02:00
f6b7443d6c i3: Go back to origin window after tab toggle 2020-10-05 22:01:56 +02:00
2c3df11fd1 Add vscode configs 2020-10-05 22:01:35 +02:00
cfd0623a3a Increase nice-ness of restic backup 2020-10-05 22:01:20 +02:00
db6ede6558 Remove git worktree script 2020-10-05 22:00:58 +02:00
a0b3db9607 Disable git commit GPG signing 2020-10-05 22:00:45 +02:00
20f5001b3c make: Add some convenience targets 2020-10-05 22:00:36 +02:00
84b58f9453 Allow per-user environment 2020-10-05 21:59:59 +02:00
21 changed files with 351 additions and 37 deletions

View File

@@ -17,6 +17,17 @@ dryrun: $(ansible)
update: $(ansible)
$(ansible_run) --tags update_system
.PHONY: reboot
reboot:
sudo reboot
.PHONY: poweroff
poweroff:
sudo poweroff
.PHONY: weekend
weekend: | update poweroff
.PHONY: packages
packages: $(ansible)
$(ansible_run) --tags packages

View File

@@ -12,14 +12,18 @@ users:
mail: hannes.koerber@tradebyte.com
git_gpg_sign: false
gpg_agent: false
environment:
MACHINE_HAS_NEXTCLOUD: "false"
- name: hannes-private
group: tpp
vt: 2
mail: hannes@hkoerber.de
git_gpg_sign: true
git_gpg_sign: false
gpg_agent: true
gpg_keys:
master_key: "0xB5C002530C6A2053"
environment:
MACHINE_HAS_NEXTCLOUD: "true"
screen:
1: DP-1-1
@@ -45,6 +49,5 @@ workspace:
environment:
MACHINE_HAS_KEEPASSX: "true"
MACHINE_HAS_NEXTCLOUD: "false"
MACHINE_HAS_RESTIC_BACKUP: "true"
MACHINE_HAS_SPOTIFY: "true"

25
bin/dunstctl Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -o nounset
_logfile="$LOGDIR/dunstctl.log"
log() {
printf '[%s] %s\n' "$(date -uIseconds)" "$*" >> "$_logfile"
}
case "$1" in
enable)
log "Enabling dunst"
systemctl --user --no-block kill --signal SIGUSR2 dunst_user
;;
disable)
log "Disabling dunst"
systemctl --user --no-block kill --signal SIGUSR1 dunst_user
;;
*)
>&2 printf 'Unknown command\n'
exit 1
esac

View File

@@ -1,21 +0,0 @@
#!/usr/bin/env bash
set -o nounset
set -o xtrace
set -o errexit
cd ./.gitdir
git fetch
if git rev-parse --verify "${1}" >/dev/null 2>&1 ; then
# local branch exists, use that
git worktree add --force ../${1} "${1}"
elif git rev-parse --verify origin/"${1}" >/dev/null 2>&1 ; then
# remove branch exists, use that
git worktree add --force -b ${1} ../${1} origin/${1}
else
git worktree add --no-track --force -b ${1} ../${1} origin/master
fi
cd ../"${1}"
git push --set-upstream origin ${1}
git submodule update --init

49
bin/paselect Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# Sinks
sinks=$(pactl list short sinks | awk '{print $2}')
chosen_sink=$(echo -e "$sinks" | rofi -dmenu -selected-row 0)
if [ "$chosen_sink" != "" ]; then
pactl set-default-sink "$chosen_sink"
fi
# Sources
sources=$(pactl list short sources | grep -h 'alsa_input' | awk '{print $2}')
chosen_source=$(echo -e "$sources" | rofi -dmenu -selected-row 0)
if [ "$chosen_source" != "" ]; then
pactl set-default-source "$chosen_source"
fi
# If nothing new has been selected -> exit gracefully now
if [ "$chosen_sink" == "" ] && [ "$chosen_source" == "" ]; then
exit 0;
fi
# Move all streams?
chosen=$(echo -e "Send all streams to new defaults?\nYes\nNo" | rofi -dmenu -selected-row 1)
if [ "$chosen" == "Yes" ]; then
if [ "$chosen_sink" != "" ]; then
pactl list short sink-inputs|while read stream; do
streamId=$(echo $stream|cut '-d ' -f1)
echo "moving stream $streamId to $chosen_sink"
pactl move-sink-input "$streamId" "$chosen_sink"
done
fi
if [ "$chosen_source" != "" ]; then
pactl list short source-outputs|while read stream; do
streamId=$(echo $stream|cut '-d ' -f1)
echo "moving stream $streamId to $chosen_source"
pactl move-source-output "$streamId" "$chosen_source"
done
fi
fi
exit 0

View File

@@ -1,2 +1,4 @@
#!/usr/bin/env bash
restic -r rclone:gdrive:restic --password-file=$HOME/restic_password backup --exclude-file=$HOME/restic_exclude.lst $HOME
nice --adjustment 19 \
ionice --class 3 \
restic -r rclone:restic:restic --password-file=$HOME/restic_password backup --exclude-file=$HOME/restic_exclude.lst $HOME

24
bin/terraform-get-targets Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Stolen from https://devops.stackexchange.com/a/8984 and adapted to my use case
if [[ -z "$@" ]]; then
echo "Missing file input arguments"
exit 1
fi
for FILE in "$@"
do
RESOURCE=$(sed -n 's/^resource "\([^"]*\)" "\([^"]*\)".*/-target=\1.\2 /gp' $FILE)
MODULE=$(sed -n 's/^module "\([^"]*\)".*/-target=module.\1 /gp' $FILE)
if [[ -z "$RESOURCE" ]] && [[ -z "$MODULE" ]]; then
echo "Cannot detect terraform resource and module in $FILE"
exit 1
fi
if [[ ! -z "$RESOURCE" ]]; then
echo -e $"$RESOURCE"
fi
if [[ ! -z "$MODULE" ]]; then
echo -e $"$MODULE"
fi
done

View File

@@ -47,3 +47,7 @@ dotfiles:
to: .config/dunstrc
- from: redshift/redshift.conf
to: .config/redshift.conf
- from: vscode/settings.json
to: .config/Code/User/settings.json
- from: vscode/keybindings.json
to: .config/Code/User/keybindings.json

View File

@@ -212,6 +212,7 @@ assign [class="^Spotify$"] $workspace9
bindsym $mod+$pim_toggle \
unmark pim_toggle; \
mark origin; \
workspace $workspace10; \
mark --add pim_toggle; \
workspace $workspace1; \
@@ -220,7 +221,9 @@ assign [class="^Spotify$"] $workspace9
move container to workspace $workspace1; \
workspace $workspace1; \
[con_mark="^pim_toggle$"] focus; \
unmark pim_toggle;
unmark pim_toggle; \
[con_mark="^origin$"] focus; \
unmark origin;
################################################################################
### MODES ######################################################################

View File

@@ -81,6 +81,7 @@ volume_status output {
thresholds = []
command = "pactl"
color_muted = '#FFFFFF'
on_click 1 = "exec $HOME/.i3/scripts/pa-volume mute-toggle"
}
volume_status input {
@@ -91,4 +92,5 @@ volume_status input {
command = "pactl"
color_muted = '#FFFFFF'
is_input = True
on_click 1 = "exec $HOME/.i3/scripts/pa-volume mute-toggle-mic"
}

View File

@@ -47,11 +47,11 @@ reset_screen() {
lock_and_screen_off() {
lock &
_pid=$!
systemctl --user --no-block kill --signal SIGUSR1 dunst_user
dunstctl disable
screen_off
xset dpms 0 0 5
wait $_pid
systemctl --user --no-block kill --signal SIGUSR2 dunst_user
dunstctl enable
reset_screen
}

View File

@@ -9,14 +9,14 @@ is_on() {
switch_on() {
touch "${_status_file}"
systemctl --user --no-block kill --signal SIGUSR1 dunst_user
dunstctl disable &
systemctl --user --no-block stop redshift_user
systemctl --user --no-block stop spotify
}
switch_off() {
rm -f "${_status_file}"
systemctl --user --no-block kill --signal SIGUSR2 dunst_user
dunstctl enable &
"$_autostart" redshift_user spotify
}

View File

@@ -81,9 +81,9 @@ packages:
i3lock:
fedora: ["i3lock"]
ubuntu: ["i3lock"]
mousepad:
fedora: ["mousepad"]
ubuntu: ["mousepad"]
pluma:
fedora: ["pluma"]
ubuntu: ["pluma"]
vim:
fedora: ["vim-enhanced"]
ubuntu: ["vim"]
@@ -285,9 +285,6 @@ packages:
expect:
fedora: []
ubuntu: ["expect"]
pluma:
fedora: []
ubuntu: ["pluma"]
inotify:
fedora: []
ubuntu: ["inotify-tools"]
@@ -312,3 +309,7 @@ packages:
anki:
fedora: ["anki"]
ubuntu: ["anki"]
remove:
mousepad:
fedora: ["mousepad"]
ubuntu: ["mousepad"]

View File

@@ -95,6 +95,16 @@
assert:
that: "defined_packages|length == distro_packages|length"
- set_fact:
defined_packages_remove: "{{ packages|json_query('keys(remove)') }}"
- set_fact:
distro_packages_remove: "{{ packages|json_query('remove.*.%s'|format(distro)) }}"
- name: check list
assert:
that: "defined_packages_remove|length == distro_packages_remove|length"
- name: install packages
package:
name: "{{ packages|json_query(query) }}"
@@ -102,6 +112,14 @@
become: true
vars:
query: "{{ 'list.*.%s[]'|format(distro) }}"
- name: remove packages
package:
name: "{{ packages|json_query(query) }}"
state: absent
become: true
vars:
query: "{{ 'remove.*.%s[]'|format(distro) }}"
tags: [packages]
- set_fact:

View File

@@ -1,6 +1,15 @@
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-save-interval '5'
set -g default-command "${SHELL}"
set -g default-terminal "rxvt-unicode"
set -g @continuum-restore 'on'
set -g set-titles on
set -g set-titles-string '#S'
setw -g automatic-rename
@@ -72,7 +81,7 @@ set -g pane-active-border-fg '#f92672'
set -g status-left " #[bg=#A6E22E,fg=#000000] #{session_name} #[bg=#272822] "
# set -g status-right "#[bg=#A6E22E,fg=#000000] #{host} #[bg=#272822] "
set -g status-right ""
set -g status-right "coninuum status: #{continuum_status}"
set -g status-left-length 100
# vertical = | in this case
@@ -97,3 +106,5 @@ bind-key -n C-F3 set-option status
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf sourced"
bind P paste-buffer
run '~/.tmux/plugins/tpm/tpm'

108
user.yml
View File

@@ -134,6 +134,16 @@
- item.stat.isdir
with_items: "{{ copy_stat.results }}"
- name: make sure target directories exist
file:
state: directory
path: "{{ (['/home', user.name, item.to]|join('/')) | dirname }}"
owner: "{{ user.name }}"
group: "{{ user_group_name }}"
with_items: "{{ dotfiles }}"
become: true
become_user: root
- name: link dotfiles
file:
state: link
@@ -315,3 +325,101 @@
with_items: "{{ user.firefox_profiles | default([]) }}"
tags:
- firefox
- block:
- name: set portfolio performance version
set_fact:
portfolio_performace_version: "0.47.0"
- name: look of current installation
stat:
path: /home/{{ user.name }}/.opt/portfolio-performance-{{ portfolio_performace_version }}
register: stat_portfolio_performance_installation
- name: create temporary directory
tempfile:
state: directory
register: tempdir
- block:
- name: download portfolio performance
get_url:
url: https://github.com/buchen/portfolio/releases/download/{{ portfolio_performace_version }}/PortfolioPerformance-{{ portfolio_performace_version }}-linux.gtk.x86_64.tar.gz
dest: "{{ tempdir.path }}/PortfolioPerformance.{{ portfolio_performace_version }}.tar.gz"
- name: create destination directory
file:
state: directory
path: "{{ tempdir.path }}/PortfolioPerformance"
when: not stat_portfolio_performance_installation.stat.exists
- name: unpack portfolio performance
unarchive:
src: "{{ tempdir.path }}/PortfolioPerformance.{{ portfolio_performace_version }}.tar.gz"
owner: "{{ user.name }}"
group: "{{ user_group_name }}"
mode: '0755'
dest: "{{ tempdir.path }}/PortfolioPerformance"
remote_src: true
- name: install portfolio performance
synchronize:
src: "{{ tempdir.path }}/PortfolioPerformance"
dest: /home/{{ user.name }}/.opt/portfolio-performance-{{ portfolio_performace_version }}
recursive: true
checksum: true
delete: true
when: not stat_portfolio_performance_installation.stat.exists
- name: link portfolio performance
file:
src: /home/{{ user.name }}/.opt/portfolio-performance-{{ portfolio_performace_version }}/PortfolioPerformance/portfolio/PortfolioPerformance
dest: /home/{{ user.name }}/.optbin/portfolio-performance
owner: "{{ user.name }}"
group: "{{ user_group_name }}"
state: link
force: true
tags:
- portfolio-performance
- block:
- name: set kubectl version
set_fact:
kubectl_version: v1.19.0
- name: get current stable version
uri:
url: https://storage.googleapis.com/kubernetes-release/release/stable.txt
return_content: true
register: kubectl_stable_version_api
- set_fact:
kubectl_stable_version: "{{ kubectl_stable_version_api.content|trim }}"
- set_fact:
kubectl_outdated: "{{ kubectl_version != kubectl_stable_version }}"
- name: warn if not on stable version
debug:
msg: "installing kubectl {{ kubectl_version }}, stable version would be {{ kubectl_stable_version }}"
changed_when: kubectl_outdated is sameas true
when: kubectl_outdated is sameas true
- name: get kubectl
get_url:
url: https://storage.googleapis.com/kubernetes-release/release/{{ kubectl_version }}/bin/linux/amd64/kubectl
dest: /home/{{ user.name }}/.opt/kubectl-{{ kubectl_version }}
owner: "{{ user.name }}"
group: "{{ user_group_name }}"
mode: '0755'
- name: link kubectl
file:
src: /home/{{ user.name }}/.opt/kubectl-{{ kubectl_version }}
dest: /home/{{ user.name }}/.optbin/kubectl
state: link
tags:
- kubectl

7
vscode/keybindings.json Normal file
View File

@@ -0,0 +1,7 @@
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+3",
"command": "workbench.action.terminal.focus"
}
]

60
vscode/settings.json Normal file
View File

@@ -0,0 +1,60 @@
{
"workbench.colorTheme": "Visual Studio Light",
"vim.neovimPath": "/usr/bin/nvim",
"explorer.confirmDelete": false,
"window.zoomLevel": 0,
"terraform.telemetry.enabled": false,
"editor.formatOnSave": true,
"vim.gdefault": true,
"vim.visualstar": true,
"vim.enableNeovim": true,
"git.detectSubmodulesLimit": 50,
"files.autoSave": "onFocusChange",
"editor.fontFamily": "'Inconsolata','Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",
"editor.accessibilitySupport": "off",
"editor.lineNumbers": "relative",
"editor.mouseWheelZoom": true,
"editor.renderWhitespace": "none",
"editor.cursorSurroundingLines": 7,
"editor.minimap.renderCharacters": false,
"editor.minimap.showSlider": "always",
"editor.minimap.size": "fill",
"files.eol": "\n",
"files.hotExit": "off",
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"workbench.enableExperiments": false,
"workbench.startupEditor": "newUntitledFile",
"workbench.activityBar.visible": false,
"workbench.iconTheme": "material-icon-theme",
"workbench.tree.indent": 12,
"window.menuBarVisibility": "toggle",
"window.title": "${rootName}${separator}${dirty}${activeEditorShort}${separator}VSCode",
"explorer.confirmDragAndDrop": false,
"explorer.incrementalNaming": "smart",
"search.smartCase": true,
"extensions.ignoreRecommendations": true,
"terminal.external.linuxExec": "urxvt",
"problems.showCurrentInStatus": true,
"problems.decorations.enabled": false,
"update.mode": "none",
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"ansible.dockerImage": "",
"vim.cursorStylePerMode.normal": "block",
"vim.cursorStylePerMode.insert": "line",
"vim.cursorStylePerMode.replace": "underline",
"vim.easymotion": true,
"vim.hlsearch": true,
"vim.leader": "<space>",
"workbench.colorCustomizations": {
"statusBar.background": "#005f5f",
"statusBar.noFolderBackground": "#005f5f",
"statusBar.debuggingBackground": "#005f5f"
},
"vim.vimrc.enable": true,
"editor.fontSize": 15,
"rust-client.disableRustup": true,
"rust-client.autoStartRls": false,
"terminal.integrated.mouseWheelScrollSensitivity": 3
}

View File

@@ -47,7 +47,8 @@ export ACPI_LID_NAME=LID
umask 0022
{% for k, v in machine.environment.items() %}
{% set env = machine.environment | combine(user.environment) %}
{% for k, v in env.items() %}
export {{ k }}="{{ v }}"
{% endfor %}

View File

@@ -33,6 +33,8 @@ alias chown="chown -c"
alias ls="ls --group-directories-first --classify --color=auto"
alias diff="diff --color=auto"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

View File

@@ -206,3 +206,7 @@ prefix() {
tmp() {
cd "$(mktemp -d)"
}
kubectl_pod() {
kubectl get pods --field-selector=status.phase=Running --selector=${1} -o jsonpath='{.items[*].metadata.name}'
}