From 38fc5157177516db195aaa2332c351cd5687374c Mon Sep 17 00:00:00 2001 From: Dan Head Date: Sat, 16 Sep 2017 15:46:03 +0100 Subject: [PATCH] i3exit script and tmpfs functions --- bin/i3exit | 30 ++++++++++++++++++++++++++++++ i3/desktop.config | 15 +++++++++++++++ vim/.vimrc | 1 + zsh/aliases.zsh | 42 +++++++++++++++++++++++++++++++++++++++++- 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100755 bin/i3exit diff --git a/bin/i3exit b/bin/i3exit new file mode 100755 index 0000000..2eb694e --- /dev/null +++ b/bin/i3exit @@ -0,0 +1,30 @@ +#!/bin/sh +lock() { + i3lock -f -c 000000 +} + +case "$1" in + lock) + lock + ;; + logout) + i3-msg exit + ;; + suspend) + lock && systemctl suspend + ;; + hibernate) + lock && systemctl hibernate + ;; + reboot) + systemctl reboot + ;; + shutdown) + systemctl poweroff + ;; + *) + echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}" + exit 2 +esac + +exit 0 diff --git a/i3/desktop.config b/i3/desktop.config index 3b7ad50..deafdd3 100644 --- a/i3/desktop.config +++ b/i3/desktop.config @@ -149,6 +149,21 @@ mode "resize" { bindsym $mod+r mode "resize" +set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown +mode "$mode_system" { + bindsym l exec --no-startup-id i3exit lock, mode "default" + bindsym e exec --no-startup-id i3exit logout, mode "default" + bindsym s exec --no-startup-id i3exit suspend, mode "default" + bindsym h exec --no-startup-id i3exit hibernate, mode "default" + bindsym r exec --no-startup-id i3exit reboot, mode "default" + bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default" + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+Pause mode "$mode_system" + # Start i3bar to display a workspace bar (plus the system information i3status # finds out, if available) bar { diff --git a/vim/.vimrc b/vim/.vimrc index 6ec26b9..0688e98 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -50,6 +50,7 @@ Plugin 'alvan/vim-closetag' Plugin 'pangloss/vim-javascript' Plugin 'junegunn/goyo.vim' Plugin 'ctrlpvim/ctrlp.vim' +Plugin 'styled-components/vim-styled-components' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index a1b7843..c646cc0 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -15,7 +15,7 @@ function android-backup() { adb backup -f "${filename}" --twrp system cache data boot recovery --compress } function mountrepo() { - if [ -e /dev/md1 ]; then + if [ -e /dev/md0 ]; then sudo cryptsetup luksOpen /dev/md0 repo if [ ! -d /mnt/repo ]; then sudo mkdir /mnt/repo @@ -40,3 +40,43 @@ function unmountrepo() { echo "Device /dev/md0 not found" fi } +alias dkr-clean="docker rm -f $(docker ps -aq) && docker rmi -f $(docker images -aq)" +alias dkr-inspect="docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1" + +function mktmpfs() { + if [ $# -eq 2 ]; then + if [ -e "$1" ]; then + echo "File/Folder ${1} already exists" + else + mkdir "$1" + sudo mount tmpfs "$1" -t tmpfs -o size="$2" + sudo chown -hR dan:dan $1 + fi + else + echo "Create a temporary file system" + echo "e.g. mktmpfs ~/temp 32m" + fi +} + +function wipetmpfs() { + if [ $# -eq 1 ]; then + if [ -e "$1" ]; then + if mount | grep "$1 type tmpfs" > /dev/null; then + read "REPLY?Are you sure you want to wipe $1? (Y/N) " + if [[ ! $REPLY =~ ^[Y]$ ]]; then + echo "Aborted" + return 1 + else + sudo umount $1 + rm -rf $1 + echo "Wiped" + fi + fi + else + echo "There's nothing at $1" + fi + else + echo "Kill a temporary file system" + echo "e.g. killtmpfs ~/temp" + fi +}