diff options
-rw-r--r-- | desktop/emacs-mail.desktop | 5 | ||||
-rwxr-xr-x | desktop/emacs.desktop | 28 | ||||
-rw-r--r-- | emacs/loader.org | 46 | ||||
-rwxr-xr-x | scripts/betterlock | 393 | ||||
-rwxr-xr-x | scripts/emacsmail | 2 | ||||
-rwxr-xr-x | scripts/hdmi | 30 | ||||
-rwxr-xr-x | scripts/i3exit | 30 | ||||
-rwxr-xr-x | scripts/mailnotify.sh | 13 | ||||
-rw-r--r-- | services/mailnotify.service | 9 | ||||
-rw-r--r-- | services/mbsync.service | 7 | ||||
-rw-r--r-- | services/mbsync.timer | 10 | ||||
-rw-r--r-- | zsh/.zsh/export.zsh | 3 |
12 files changed, 559 insertions, 17 deletions
diff --git a/desktop/emacs-mail.desktop b/desktop/emacs-mail.desktop new file mode 100644 index 0000000..0739de1 --- /dev/null +++ b/desktop/emacs-mail.desktop @@ -0,0 +1,5 @@ +[Desktop Entry] +Type=Application +Name=Emacs Email +Exec=emacsclient -c --eval "(browse-url-mail \"%f\")" +Icon=/home/yannherklotz/Images/emacs.icon diff --git a/desktop/emacs.desktop b/desktop/emacs.desktop new file mode 100755 index 0000000..95df61e --- /dev/null +++ b/desktop/emacs.desktop @@ -0,0 +1,28 @@ +[Desktop Entry] + +# The type as listed above +Type=Application + +# The version of the desktop entry specification to which this file complies +Version=1.0 + +# The name of the application +Name=Emacs + +# A comment which can/will be used as a tooltip +Comment=Flash card based learning tool + +# The path to the folder in which the executable is run +Path=/home/yannherklotz + +# The executable of the application, possibly with arguments. +Exec=/usr/bin/emacsclient -c -a '/usr/bin/emacs' + +# The name of the icon that will be used to display this entry +Icon=/home/yannherklotz/Images/emacs.icon + +# Describes whether this application needs to be run in a terminal or not +Terminal=false + +# Describes the categories in which this entry should be shown +Categories=Languages;Editor;Text; diff --git a/emacs/loader.org b/emacs/loader.org index 2808490..5d300ee 100644 --- a/emacs/loader.org +++ b/emacs/loader.org @@ -72,6 +72,9 @@ be used to load any file in that directory. (interactive "f") "Load a file in current user's configuration directory" (load-file (expand-file-name file user-init-dir))) + + (setq load-path + (cons (expand-file-name "~/.emacs.d/modes") load-path)) #+END_SRC ** Repositories @@ -160,6 +163,10 @@ buffer instead. (global-visual-line-mode t) #+end_src +#+begin_src emacs-lisp + (global-visual-line-mode t) +#+end_src + *** Custom modeline Editing the modeline. ~%c~ might be a bit slow though, so that could be removed @@ -514,10 +521,6 @@ Set navigation commands in all the buffers (interactive) (other-window -1)) -;; (use-package golden-ratio -;; :config -;; (golden-ratio-mode)) - (defun push-mark-no-activate () "Pushes `point' to `mark-ring' and does not activate the region Equivalent to \\[set-mark-command] when \\[transient-mark-mode] is disabled" @@ -686,8 +689,6 @@ incrementally selecting more and more of the text. (use-package yasnippet :config (yas-global-mode)) - - (use-package yasnippet-snippets) #+END_SRC ** Tramp @@ -781,7 +782,7 @@ Markdown is the standard for writing documentation. This snippet loads GFM org-directory (expand-file-name "~/Dropbox/org") org-image-actual-width nil org-format-latex-options (plist-put org-format-latex-options :scale 1.5) - org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f") + org-latex-pdf-process (list "latexmk -lualatex -shell-escape -bibtex -f -pdf %f") org-default-notes-file (concat org-directory "/inbox.org") org-image-actual-width nil org-export-allow-bind-keywords t) @@ -956,6 +957,14 @@ Add org noter #+RESULTS: | pdf-view-mode | +** Writeroom + +#+begin_src emacs-lisp + (use-package writeroom-mode + :config + (setq writeroom-width 100)) +#+end_src + * Programming My emacs configuration is mostly focused on programming, therefore there is a lot of different language support. @@ -966,15 +975,7 @@ lot of different language support. (use-package magit :bind (("C-x g" . magit-status)) :config - (setq server-switch-hook nil) - (defadvice forge-create-issue (after adjust-window activate) - "Adjust the window size using the golden-ratio package when - creating a new issue" - (golden-ratio)) - (defadvice magit-status (after adjust-window activate) - "Adjust the window size using the golden-ratio package when - getting the status of a repository." - (golden-ratio))) + (setq server-switch-hook nil)) #+END_SRC #+RESULTS: @@ -1147,6 +1148,12 @@ F# mode for uni work. (lambda () (local-set-key (kbd "C-c C-c") #'y/fsharp-reload-file)))) #+END_SRC +*** Flex + +#+begin_src emacs-lisp + (add-to-list 'auto-mode-alist '("\\.flex\\'" . c-mode)) +#+end_src + *** Haskell Haskell mode with company mode completion. @@ -1186,6 +1193,13 @@ Haskell mode with company mode completion. #+RESULTS: | (lambda nil (set (make-local-variable (quote projectile-tags-command)) hasktags -Re -f "%s" %s "%s")) | (lambda nil (local-set-key (kbd C-c v) (quote haskell-add-import))) | (lambda nil (local-set-key (kbd C-c y a) (quote y/haskell-align-comment))) | haskell-decl-scan-mode | interactive-haskell-mode | +*** LLVM IR + +#+begin_src emacs-lisp + (when (file-exists-p "~/.emacs.d/modes/llvm-mode.el") + (require 'llvm-mode)) +#+end_src + *** HOL #+begin_src emacs-lisp diff --git a/scripts/betterlock b/scripts/betterlock new file mode 100755 index 0000000..d9f90af --- /dev/null +++ b/scripts/betterlock @@ -0,0 +1,393 @@ +#!/usr/bin/env bash + +# Author : Pavan Jadhaw +# Github Profile : https://github.com/pavanjadhaw +# Project Repository : https://github.com/pavanjadhaw/betterlockscreen + +# find your resolution so images can be resized to match your screen resolution +res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') +locktext='Type password to unlock...' + + +init_filenames() { + #$1 resolution + + # create folder in ~/.cache/i3lock directory + res_folder="$HOME/.cache/i3lock/$1" + folder="$HOME/.cache/i3lock/current" + echo "Got" $@ $res_folder + if [ ! -d $folder -o -n "$2" ]; then + rm -f $folder + ln -s $res_folder $folder + fi + + # ratio for rectangle to be drawn for time background on lockscreen + # Original Image + orig_wall="$folder/wall.png" + + # Versions (from here) + # You can use these images to set different versions as wallpaper + # lockscreen background. + resized="$folder/resized.png" # resized image for your resolution + + # images to be used as wallpaper + dim="$folder/dim.png" # image with subtle overlay of black + blur="$folder/blur.png" # blurred version + dimblur="$folder/dimblur.png" + + # lockscreen images (images to be used as lockscreen background) + l_resized="$folder/l_resized.png" + l_dim="$folder/l_dim.png" + l_blur="$folder/l_blur.png" + l_dimblur="$folder/l_dimblur.png" +} + +init_filenames $res + + +prelock() { + if [ ! -z "$(pidof dunst)" ]; then + pkill -u "$USER" -USR1 dunst + fi +} + + +lock() { + #$1 image path + letterEnteredColor=d23c3dff + letterRemovedColor=d23c3dff + passwordCorrect=00000000 + passwordIncorrect=d23c3dff + background=00000000 + foreground=ffffffff + i3lock \ + -t -i "$1" \ + --timepos='x+110:h-70' \ + --datepos='x+43:h-45' \ + --clock --date-align 1 --datestr "$locktext" \ + --insidecolor=$background --ringcolor=$foreground --line-uses-inside \ + --keyhlcolor=$letterEnteredColor --bshlcolor=$letterRemovedColor --separatorcolor=$background \ + --insidevercolor=$passwordCorrect --insidewrongcolor=$passwordIncorrect \ + --ringvercolor=$foreground --ringwrongcolor=$foreground --indpos='x+280:h-70' \ + --radius=20 --ring-width=4 --veriftext='' --wrongtext='' \ + --verifcolor="$foreground" --timecolor="$foreground" --datecolor="$foreground" \ + --noinputtext='' --force-clock $lockargs +} + + +postlock() { + if [ ! -z "$(pidof dunst)" ] ; then + pkill -u "$USER" -USR2 dunst + fi +} + + +rec_get_random() { + dir="$1" + if [ ! -d "$dir" ]; then + user_input="$dir" + return + fi + dir=($dir/*) + dir=${dir[RANDOM % ${#dir[@]}]} + rec_get_random "$dir" +} + + +lockselect() { + prelock + case "$1" in + dim) + # lockscreen with dimmed background + lock "$l_dim" + ;; + + blur) + # set lockscreen with blurred background + lock "$l_blur" + ;; + + dimblur) + # set lockscreen with dimmed + blurred background + lock "$l_dimblur" + ;; + + *) + # default lockscreen + lock "$l_resized" + ;; + esac + postlock +} + + +update() { + # use + background="$1" + + # default blur level; fallback to 1 + [[ $blur_level ]] || blur_level=1 + + rectangles=" " + SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') + for RES in $SR; do + SRA=(${RES//[x+]/ }) + CX=$((${SRA[2]} + 25)) + CY=$((${SRA[1]} - 30)) + rectangles+="rectangle $CX,$CY $((CX+300)),$((CY-80)) " + done + + # User supplied Image + user_image="$folder/user_image.png" + + # create folder + if [ ! -d $folder ]; then + echo "Creating '$folder' directory to cache processed images." + mkdir -p "$folder" + fi + + # get random file in dir if passed argument is a dir + rec_get_random "$background" + + # get user image + cp "$user_input" "$user_image" + if [ ! -f $user_image ]; then + echo 'Please specify the path to the image you would like to use' + exit 1 + fi + + # replace orignal with user image + cp "$user_image" "$orig_wall" + rm "$user_image" + + echo 'Generating alternate images based on the image you specified,' + echo 'please wait this might take few seconds...' + + # wallpapers + + echo + echo 'Converting provided image to match your resolution...' + # resize image + convert "$orig_wall" -resize "$res""^" -gravity center -extent "$res" "$resized" + + echo + echo 'Applying dim and blur effect to resized image' + # dim + convert "$resized" -fill black -colorize 40% "$dim" + + # blur + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + convert "$resized" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$res^" -gravity center -extent "$res" \ + "$blur" + + # dimblur + convert "$dim" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$res^" -gravity center -extent "$res" \ + "$dimblur" + + # lockscreen backgrounds + + echo + echo 'Caching images for faster screen locking' + # resized + convert "$resized" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_resized" + + # dim + convert "$dim" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_dim" + + # blur + convert "$blur" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_blur" + + # blur + convert "$dimblur" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_dimblur" + echo + echo 'All required changes have been applied' +} + + +wallpaper() { + case "$1" in + '') + # set resized image as wallpaper if no argument is supplied by user + feh --bg-fill $resized + ;; + + dim) + # set dimmed image as wallpaper + feh --bg-fill $dim + ;; + + blur) + # set blurred image as wallpaper + feh --bg-fill $blur + ;; + + dimblur) + # set dimmed + blurred image as wallpaper + feh --bg-fill $dimblur + ;; + esac +} + + +empty() { + if [ -f $l_dim ]; then + echo -e "\nSeems you haven't provided any arguments. See below for usage details." + else + echo 'Important: Update the image cache (e.g. betterlockscreen -u path/to/image.jpg).' + echo + echo ' Image cache must be updated to initially configure or update the wallpaper used.' + fi + + echo + echo 'For other sets of options and help, use the help command.' + echo 'e.g. betterlockscreen -h or betterlockscreen --help' + echo + echo 'See: https://github.com/pavanjadhaw/betterlockscreen for additional info...' + exit 1 +} + + +usage() { + echo 'Important: Update the image cache (e.g. betterlockscreen -u path/to/image.jpg).' + echo ' Image cache must be updated to initially configure or update wallpaper used' + echo + echo + echo 'See: https://github.com/pavanjadhaw/betterlockscreen for additional info...' + echo + echo + echo 'Options:' + echo + echo ' -h --help' + echo ' For help (e.g. betterlockscreen -h or betterlockscreen --help).' + echo + echo + echo ' -u --update' + echo ' to update image cache, you should do this before using any other options' + echo ' E.g: betterlockscreen -u path/to/image.png when image.png is custom background' + echo ' Or you can use betterlockscreen -u path/to/imagedir and a random file will be selected.' + echo + echo + echo ' -l --lock' + echo ' to lock screen (e.g. betterlockscreen -l)' + echo ' you can also use dimmed or blurred background for lockscreen.' + echo ' E.g: betterlockscreen -l dim (for dimmed background)' + echo ' E.g: betterlockscreen -l blur (for blurred background)' + echo ' E.g: betterlockscreen -l dimblur (for dimmed + blurred background)' + echo + echo + echo ' -s --suspend' + echo ' to suspend system and lock screen (e.g. betterlockscreen -s)' + echo ' you can also use dimmed or blurred background for lockscreen.' + echo ' E.g: betterlockscreen -s dim (for dimmed background)' + echo ' E.g: betterlockscreen -s blur (for blurred background)' + echo ' E.g: betterlockscreen -s dimblur (for dimmed + blurred background)' + echo + echo + echo ' -w --wall' + echo ' you can also set lockscreen background as wallpaper' + echo ' to set wallpaper (e.g. betterlockscreen -w or betterlockscreen --wall)' + echo ' you can also use dimmed or blurred variants.' + echo ' E.g: betterlockscreen -w dim (for dimmed wallpaper)' + echo ' E.g: betterlockscreen -w blur (for blurred wallpaper)' + echo ' E.g: betterlockscreen -w dimblur (for dimmed + blurred wallpaper)' + echo + echo + echo ' -r --resolution' + echo ' to be used after -u' + echo ' used to set a custom resolution for the image cache.' + echo ' E.g: betterlockscreen -u path/to/image.png -r 1920x1080' + echo ' E.g: betterlockscreen -u path/to/image.png --resolution 3840x1080' + echo + echo + echo ' -b --blur' + echo ' to be used after -u' + echo ' used to set blur intensity. Default to 1.' + echo ' E.g: betterlockscreen -u path/to/image.png -b 3' + echo ' E.g: betterlockscreen -u path/to/image.png --blur 0.5' + echo + echo + echo ' -t --text' + echo ' to set custom lockscreen text (max 31 chars)' + echo " E.g: betterlockscreen -l dim -t \"Don't touch my machine!\"" + echo ' E.g: betterlockscreen --text "Hi, user!" -s blur' +} + + +# Options +[[ "$1" = '' ]] && empty + +for arg in "$@"; do + [[ "${arg:0:1}" = '-' ]] || continue + + case "$1" in + -h | --help) + usage + break + ;; + + -s | --suspend) + runsuspend=true + ;& + + -l | --lock) + runlock=true + [[ $runsuspend ]] || lockargs="$lockargs -n" + [[ ${2:0:1} = '-' ]] && shift 1 || { lockstyle="$2"; shift 2; } + ;; + + -w | --wall | --wallpaper) + wallpaper "$2" + shift 2 + ;; + + -u | --update) + runupdate=true + imagepath="$2" + shift 2 + ;; + + -t | --text) + locktext="$2" + shift 2 + ;; + + -r | --resolution) + res="$2" + init_filenames $res force + shift 2 + ;; + + -b | --blur) + blur_level="$2" + shift 2 + ;; + + --) + lockargs="$lockargs ${@:2}" + break + ;; + + *) + echo "invalid argument: $1" + break + ;; + esac +done + +# Run image generation +[[ $runupdate ]] && update "$imagepath" + +# Activate lockscreen +[[ $runlock ]] && lockselect "$lockstyle" && \ + { [[ $runsuspend ]] && systemctl suspend; } + +exit 0 diff --git a/scripts/emacsmail b/scripts/emacsmail new file mode 100755 index 0000000..8e7fa45 --- /dev/null +++ b/scripts/emacsmail @@ -0,0 +1,2 @@ +#!/bin/bash +emacsclient -c --eval "(browse-url-mail \"$@\")" diff --git a/scripts/hdmi b/scripts/hdmi new file mode 100755 index 0000000..702c947 --- /dev/null +++ b/scripts/hdmi @@ -0,0 +1,30 @@ +#!/usr/bin/bash + +case $1 in + -l|--left) + xrandr --output DP-1 --left-of eDP-1 --auto;; + -r|--right) + xrandr --output DP-1 --right-of eDP-1 --auto;; + -o|--off) + xrandr --output DP-1 --off --auto;; + -t|--rotate) + xrandr --output DP-1 --rotate left --right-of eDP-1 --auto;; + --reload);; + *) + echo <<- EOF +hdmi: Simple wrapper around xrandr to set the external display + appropriately, with the options mostly premade. + + Options: + -l,--left Screen to the left of main. + -r,--right Screen to the right of main. + -o,--off Turn the other screen off. + -r,--rotate Rotate the screen left. + --reload Only reload the session. +EOF +exit 0;; +esac + +~/.config/bspwm/bspwmrc >/dev/null 2>&1 & +~/.fehbg >/dev/null 2>&1 + diff --git a/scripts/i3exit b/scripts/i3exit new file mode 100755 index 0000000..9e3f3a1 --- /dev/null +++ b/scripts/i3exit @@ -0,0 +1,30 @@ +#!/bin/sh +lock() { + $HOME/.local/bin/betterlock -$1 blur +} + +case "$1" in + lock) + lock l + ;; + logout) + i3-msg exit + ;; + suspend) + lock s + ;; + 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/scripts/mailnotify.sh b/scripts/mailnotify.sh new file mode 100755 index 0000000..0c22e57 --- /dev/null +++ b/scripts/mailnotify.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +mail=${HOME}/.mail/imperial/Inbox/new + +inotifywait -m ${mail} | while read line; do + if [[ $line =~ .*MOVED_TO ]] || [[ $line =~ .*CREATE ]]; then + filename=$(echo "$line" | sed -E 's/[[:space:]]+((MOVED_TO)|(CREATE))[[:space:]]+//') + subject=$(grep '^Subject:' $filename | sed -E 's/^Subject:[[:space:]]+//') + from=$(grep '^From:' $filename | sed -E 's/^From:[[:space:]]+//') + dunstify -i mail-unread "$from +$subject" "" & + fi +done diff --git a/services/mailnotify.service b/services/mailnotify.service new file mode 100644 index 0000000..8e11656 --- /dev/null +++ b/services/mailnotify.service @@ -0,0 +1,9 @@ +[Unit] +Description=Mailbox notification service + +[Service] +Type=simple +ExecStart=/home/yannherklotz/.local/bin/mailnotify.sh + +[Install] +WantedBy=default.target diff --git a/services/mbsync.service b/services/mbsync.service new file mode 100644 index 0000000..5d74edb --- /dev/null +++ b/services/mbsync.service @@ -0,0 +1,7 @@ +[Unit] +Description=Mailbox synchronization service +After=network.target network-online.target dbus.socket + +[Service] +Type=oneshot +ExecStart=/usr/bin/mbsync -Va diff --git a/services/mbsync.timer b/services/mbsync.timer new file mode 100644 index 0000000..bd6ba12 --- /dev/null +++ b/services/mbsync.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Mailbox synchronization timer + +[Timer] +OnBootSec=2m +OnUnitActiveSec=2m +Unit=mbsync.service + +[Install] +WantedBy=timers.target diff --git a/zsh/.zsh/export.zsh b/zsh/.zsh/export.zsh index ad49a65..78cff50 100644 --- a/zsh/.zsh/export.zsh +++ b/zsh/.zsh/export.zsh @@ -1,4 +1,5 @@ export GITHUB_HOME=$HOME/Github +export FZF_DEFAULT_COMMAND='fd --type file --hidden --no-ignore' export ALTERNATE_EDITOR="emacs -nw -Q" export EDITOR='emacsclient -nw' export VISUAL='emacsclient -c' @@ -12,7 +13,7 @@ export PATH="${PATH}:/opt/intelFPGA_lite/18.1/quartus/bin" export PATH="${HOME}/.local/bin:${PATH}" export PATH="${HOME}/.cargo/bin:${PATH}" export PATH="${HOME}/.cabal/bin:${PATH}" -export PATH="${HOME}/.gem/ruby/2.7.0/bin:${PATH}" +if [[ -d "${HOME}/.gem/ruby/2.7.0/bin" ]]; then export PATH="${HOME}/.gem/ruby/2.7.0/bin:${PATH}"; fi # Stop dotnet telemetry export DOTNET_CLI_TELEMETRY_OPTOUT=1 |