├── .Xresources ├── .asy ├── config.asy └── piechart.asy ├── .config ├── blender │ └── 2.72 │ │ └── config │ │ └── userpref.blend ├── cron │ └── job.guile ├── demlo │ ├── config.lua │ └── scripts │ │ ├── 00-tag-const.lua │ │ ├── 11-tag-soundtrack.lua │ │ ├── 51-encoding-flac2ogg.lua │ │ ├── 52-encoding-ogg.lua │ │ ├── 58-path-newlib.lua │ │ ├── 59-path-humour.lua │ │ ├── 59-path-sync.lua │ │ └── xray.lua ├── mps-youtube │ └── config ├── qutebrowser │ └── config.py ├── ranger │ └── scope.sh ├── sxiv │ └── exec │ │ ├── image-info │ │ └── key-handler └── transmission-daemon │ └── settings.json ├── .conkyrc ├── .emacs.d ├── .dir-locals.el ├── init.el └── lisp │ ├── functions.el │ ├── init-bbcode.el │ ├── init-cc.el │ ├── init-dired.el │ ├── init-elfeed.el │ ├── init-emms.el │ ├── init-engine.el │ ├── init-eshell.el │ ├── init-evil-gnus.el │ ├── init-evil.el │ ├── init-eww.el │ ├── init-exwm.el │ ├── init-flycheck.el │ ├── init-go.el │ ├── init-gud.el │ ├── init-helm.el │ ├── init-latex.el │ ├── init-lisp.el │ ├── init-lua.el │ ├── init-makefile.el │ ├── init-markdown.el │ ├── init-mediawiki.el │ ├── init-mu4e.el │ ├── init-nroff.el │ ├── init-org.el │ ├── init-python.el │ ├── init-sh.el │ ├── init-term.el │ ├── init-tex.el │ ├── main.el │ ├── package-eshell-detach.el │ ├── patch-desktop.el │ ├── patch-eshell-26.el │ ├── patch-page.el │ ├── patch-smie.el │ └── visual.el ├── .gitconfig ├── .gitignore ├── .gnupg ├── gpg-agent.conf └── gpg.conf ├── .guix-config └── config.scm ├── .guix-packages ├── tex.scm └── unrar.scm ├── .local ├── bin │ ├── .tc-video-custom.in │ ├── asciify │ ├── bsdman │ ├── clonecd │ ├── cpuusage │ ├── crun │ ├── cxev │ ├── dataindex │ ├── demlo-sync │ ├── echokeymap │ ├── echopath │ ├── ediff │ ├── einfo │ ├── elisp │ ├── em │ ├── email │ ├── emc │ ├── emw │ ├── git-get │ ├── gnac │ ├── hdmi-switch │ ├── homeclean │ ├── homeinit │ ├── homesync │ ├── imagemount │ ├── lsofstat │ ├── ltx │ ├── medialinter │ ├── mediastats │ ├── mover │ ├── myip │ ├── netmap │ ├── netscan │ ├── netspeed │ ├── obsdman │ ├── pacman │ │ ├── pacfiles │ │ ├── pachist │ │ ├── pacman-diff │ │ └── pacsize │ ├── pdfctl │ ├── pkglister │ ├── preview │ ├── probe │ ├── rcopy │ ├── rdiff │ ├── realpath │ ├── renamelower │ ├── renameswap │ ├── replace │ ├── rmirror │ ├── sanitize │ ├── scanner │ ├── strip-comments │ ├── tc-video-custom │ ├── tc-video-generic │ ├── termctl │ ├── texclean │ ├── tlctl │ ├── transfer │ ├── transmission-auto │ ├── udisks-automount │ ├── updatedb-local │ ├── utf8fy │ ├── weather │ ├── winefps │ ├── worldtime │ └── xctl └── share │ └── applications │ └── mimeapps.list ├── .mailcap ├── .mpv ├── config └── input.conf ├── .pkglists ├── arch-aur ├── arch-noob ├── arch-official ├── guix └── texlive ├── .profile ├── .toprc ├── .uncrustify.cfg ├── .units ├── .xbindkeysrc ├── .xinitrc ├── .xkb ├── symbols │ └── usim └── usim.xkb ├── .xprofile ├── .xsession └── README.md /.Xresources: -------------------------------------------------------------------------------- 1 | !! Xft options 2 | ! Xft.antialias: false 3 | ! Xft.antialias: rgba 4 | Xft.hinting: true 5 | Xft.hintstyle: hintlight 6 | Xft.rgba: rgb 7 | 8 | !! Xterm 9 | xterm*termName: xterm-256color 10 | xterm*locale: true 11 | ! XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48 12 | ! xterm.font: xft:Dina:pixelsize=18 13 | ! xterm*font : -*-dejavu sans-medium-r-*-*-14-*-*-*-*-*-*-* 14 | xterm*faceName:DejaVu Sans Mono:pixelsize=14 15 | !! Make Meta-* bindings work. 16 | xterm*eightBitInput: false 17 | !! Fix the backspace key 18 | xterm*backarrowKey: false 19 | xterm*ttyModes: erase ^? 20 | xterm*saveLines: 4096 21 | xterm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48 22 | xterm*on3Clicks: regex ([[:alpha:]]+://)?([[:alnum:]!#+,./=?@_~-]|(%[[:xdigit:]][[:xdigit:]]))+ 23 | 24 | xterm*background: black 25 | xterm*foreground: white 26 | xterm*color0 : black 27 | xterm*color1 : #8b0000 28 | xterm*color2 : #228b22 29 | xterm*color3 : #cdcd00 30 | xterm*color4 : blue 31 | xterm*color5 : #8b008b 32 | xterm*color6 : #00bfff 33 | xterm*color7 : #f5f5f5 34 | xterm*color8 : #696969 35 | xterm*color9 : red 36 | xterm*color10 : green 37 | xterm*color11 : yellow 38 | xterm*color12 : #1e90ff 39 | xterm*color13 : magenta 40 | xterm*color14 : cyan 41 | xterm*color15 : white 42 | -------------------------------------------------------------------------------- /.asy/config.asy: -------------------------------------------------------------------------------- 1 | import settings; 2 | psviewer="zathura"; 3 | pdfviewer="zathura"; 4 | -------------------------------------------------------------------------------- /.asy/piechart.asy: -------------------------------------------------------------------------------- 1 | /* Example of use: 2 | 3 | access piechart; 4 | unitsize (70); 5 | 6 | int[] values = {1, 2, 3, 2}; 7 | string[] labels = {"a", "b", "c", "very long"}; 8 | 9 | add(piechart.pie(values, labels, 1.2, green, labelcolor=blue)); 10 | */ 11 | 12 | picture pie (int[] values, string[] labels={}, real distance = 0.5, pen color = rgb(1,1,1), pen labelcolor = rgb(0, 0, 0)) { 13 | picture opic; 14 | // unitsize(100); 15 | int total = 0; 16 | for (int i: values) { 17 | total += i; 18 | } 19 | 20 | if (total != 0) { 21 | real last = 0; 22 | for (int i = 0; i < values.length; ++i) { 23 | real current = last+values[i]*360/total; 24 | filldraw(opic, arc((0,0), 1, last, current) -- (0,0) -- cycle, values[i]/total * color); 25 | if (labels.length == values.length) { 26 | // rotate() 0 angle is upwards. We shift it to match the trigonometric circle. 27 | label (opic, labels[i], rotate((current+last)/2-90) * (0, distance), labelcolor); 28 | } 29 | last = current; 30 | } 31 | } 32 | return opic; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /.config/blender/2.72/config/userpref.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ambrevar/dotfiles/25e2ed350b898c3fc2df3148630b5778a3db4ee7/.config/blender/2.72/config/userpref.blend -------------------------------------------------------------------------------- /.config/cron/job.guile: -------------------------------------------------------------------------------- 1 | ;; -*- mode: Lisp; -*- 2 | 3 | ;; This cannot be let-bound within `job'. 4 | (define currency-file (string-append (getenv "HOME") "/.cache/currency.units")) 5 | 6 | (job 7 | (lambda (current-time) 8 | (let* ((seconds-in-a-day (* 60 60 24)) 9 | (currency-time (stat:mtime (stat currency-file)))) 10 | (if (< currency-time (- current-time seconds-in-a-day)) 11 | ;; Use next-minute to avoid overwhelming the system in case of failure. 12 | (next-minute) 13 | (next-hour-from (next-day) (list (tm:hour (localtime currency-time))))))) 14 | ;; A string is nicer than Scheme code for `mcron --schedule' output. 15 | ;; Otherwise we could return '(system* "units_cur" currency-file) 16 | ;; and use job's 3rd argument as a description. 17 | (string-append "units_cur " currency-file)) 18 | 19 | (job '(next-hour '(3)) "updatedb-local") 20 | -------------------------------------------------------------------------------- /.config/demlo/config.lua: -------------------------------------------------------------------------------- 1 | --[[ Demlo configuration file 2 | All the commandline options can get a default value from here. 3 | Commandline values take precedence. 4 | --]] 5 | 6 | -- Colors may not work on all terminals. 7 | Color = true 8 | 9 | -- Number of cores to use (0 for all). 10 | Cores = 0 11 | 12 | --[[ When the destination exit, the "exist" action is taken. 13 | An action is a Lua script which sets the variable 'output.write' to the following possible values: 14 | - "overwrite": overwrite. 15 | - "skip": don't do anything. 16 | - nil (or anything else): append a random suffix to the new file. 17 | 18 | The following variable specifies the path or name of the default action script. 19 | --]] 20 | Exist = '' 21 | 22 | -- Extensions to look for when a folder is browsed. 23 | -- The following variable is a map which keys are the extensions and the values are 'true'. 24 | Extensions = {} 25 | ext = {'aac', 'ape', 'flac', 'm4a', 'mp3', 'mp4', 'mpc', 'ogg', 'wav', 'wv'} 26 | for _, v in ipairs(ext) do 27 | Extensions[v]=true 28 | end 29 | 30 | -- Whther to fetch cover from an online database. 31 | -- Since Internet queries slow down the process, it's recommended to only turn 32 | -- it on from the commandline when needed. 33 | Getcover = false 34 | 35 | -- Fetch tags from an online database. 36 | -- Since Internet queries slow down the process, it's recommended to only turn 37 | -- it on from the commandline when needed. 38 | Gettags = false 39 | 40 | -- Lua code to run before and after the other scripts, respectively. 41 | Prescript = '' 42 | Postscript = '' 43 | 44 | -- If false, show preview and exit before processing. 45 | Process = false 46 | 47 | -- Scripts to run by default. 48 | -- Scripts can later be added or removed via the commandline. 49 | -- Demlo runs them in lexicographic order. 50 | -- Thus the names matter, e.g. 'path' can be influenced by the modifications 51 | -- made by 'tag', so we name the scripts with a prefix number so that 'tag' is 52 | -- run before 'path'. 53 | Scripts = {'10-tag-normalize', '15-tag-disc_from_path', '20-tag-replace', '30-tag-case', '40-tag-punctuation', '50-encoding', '60-path', '70-cover', 54 | '00-const', '51-encoding-flac2ogg', '59-humour'} 55 | -------------------------------------------------------------------------------- /.config/demlo/scripts/00-tag-const.lua: -------------------------------------------------------------------------------- 1 | -- Constants 2 | 3 | const = const or {} 4 | 5 | const_custom = { 6 | 'AC', 7 | 'BYOB', 8 | 'DC', 9 | 'DMX', 10 | 'FBI', 11 | 'MGMT', 12 | 'RZA', 13 | 'SWAT', 14 | 'USA', 15 | 'USSR', 16 | 'AIDS', 17 | 'DNA', 18 | 'DVD', 19 | 'FM', 20 | 'JFK', 21 | 'JBX', 22 | "d'Acide", 23 | 24 | --French 25 | 'avec', 26 | 'chez', 27 | 'dans', 28 | 'de', 29 | 'des', 30 | 'du', 31 | 'le', 32 | 'la', 33 | 'les', 34 | 'que', 35 | 'qui', 36 | 'quoi', 37 | 'sur', 38 | 'un', 39 | 'une', 40 | 41 | -- German 42 | 'der', 43 | 'die', 44 | 'das', 45 | 'den', 46 | 'dem', 47 | 'des', 48 | 'ein', 49 | 'eine', 50 | 'einen', 51 | 'eines', 52 | 'einer', 53 | 'einem', 54 | 'im', 55 | 'wo', 56 | 'an', 57 | 'am', 58 | 'in', 59 | 'bei', 60 | 'aus', 61 | 'mit', 62 | 'nach', 63 | 'seit', 64 | 'von', 65 | 'zu', 66 | 'vom', 67 | 'zur', 68 | 'zum', 69 | 'durch', 70 | 'für', 71 | 'gegen', 72 | 'ohne', 73 | 'um', 74 | 75 | -- Spanish 76 | 'y', 77 | } 78 | 79 | for _, v in ipairs(const_custom) do 80 | const[#const+1] = v 81 | end 82 | -------------------------------------------------------------------------------- /.config/demlo/scripts/11-tag-soundtrack.lua: -------------------------------------------------------------------------------- 1 | -- Soundtrack tags. 2 | if stringrel(stringnorm (o.genre), 'soundtrack') > 0.7 then 3 | o.album_artist = o.album 4 | end 5 | -------------------------------------------------------------------------------- /.config/demlo/scripts/51-encoding-flac2ogg.lua: -------------------------------------------------------------------------------- 1 | -- Keep result of 'encoding.lua' except flac. 2 | 3 | local bitrate = bps or 9999999 4 | local bitrate_max = 192000 5 | 6 | if output.format == 'flac' then 7 | if bitrate > input.bitrate then 8 | bitrate = input.bitrate 9 | end 10 | output.format = 'ogg' 11 | output.parameters = {'-c:a', 'libvorbis', '-b:a', tostring(math.min(bitrate, bitrate_max))} 12 | end 13 | -------------------------------------------------------------------------------- /.config/demlo/scripts/52-encoding-ogg.lua: -------------------------------------------------------------------------------- 1 | -- Force output to OGG. 2 | 3 | local bitrate = bps or 9999999 4 | local bitrate_max = 192000 5 | 6 | if bitrate > input.bitrate then 7 | bitrate = input.bitrate 8 | end 9 | 10 | output.parameters = {'-c:a', 'libvorbis', '-b:a', tostring(math.min(bitrate, bitrate_max))} 11 | 12 | output.format = 'ogg' 13 | -------------------------------------------------------------------------------- /.config/demlo/scripts/58-path-newlib.lua: -------------------------------------------------------------------------------- 1 | -- Change default destination. 2 | lib=os.getenv("HOME") .. "/music_new" 3 | -------------------------------------------------------------------------------- /.config/demlo/scripts/59-path-humour.lua: -------------------------------------------------------------------------------- 1 | -- Output 'humour' genre to a separate library. 2 | -- Run before 'path'. 3 | 4 | local ossep = osseperator or '/' 5 | 6 | local genre = o.genre and o.genre:lower():gsub([[\s]],'_') 7 | if genre and genre == 'humour' then 8 | library = os.getenv('HOME') .. ossep .. 'humour' 9 | else 10 | library = os.getenv('HOME') .. ossep .. 'music' 11 | end 12 | -------------------------------------------------------------------------------- /.config/demlo/scripts/59-path-sync.lua: -------------------------------------------------------------------------------- 1 | help("Set 'pathsub' to be VFAT friendly. See path.lua.") 2 | pathsub = {{'["*?:/\|<>]', ""}} 3 | -------------------------------------------------------------------------------- /.config/demlo/scripts/xray.lua: -------------------------------------------------------------------------------- 1 | -- X-Ray Dog 2 | -- WARNING: Untested. 3 | 4 | -- Remove all default tags. 5 | tags = {} 6 | 7 | tags.artist = 'X-Ray Dog' 8 | -- Albums actually have years, but is it relevent since they have a code? 9 | tags.date = '' 10 | -- Genre could be Soundtrack, or Trailer Music. We choose '' for now. 11 | tags.genre = '' 12 | 13 | -- Extract album code, assuming parent folder is 'XRCD## - $album'. 14 | XRCD = output.filename:match('/[^/]*(XRCD\d*)[^/]*/[^/]*$') 15 | 16 | -- Append the album code to the constants array, other it will be capitalized. 17 | constants [XRCD:upper()] = XRCD 18 | 19 | tags.album = not empty (o.album) and o.album:gsub ('XRCD - (\d+)', 'XRCD$1 - ') or 'Unknown album' 20 | 21 | tags.title = o.title 22 | if empty(tags.title) then 23 | tags.title = output.filename:match('[^/]+$'):gsub('\..+$', ''):gsub('X-Ray Dog[\s*?]*', '') 24 | end 25 | 26 | tags.track = o.track 27 | if empty(tags.track) then 28 | tags.track = o.title:match('\d+') 29 | end 30 | 31 | output.tags = tags 32 | -------------------------------------------------------------------------------- /.config/mps-youtube/config: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ambrevar/dotfiles/25e2ed350b898c3fc2df3148630b5778a3db4ee7/.config/mps-youtube/config -------------------------------------------------------------------------------- /.config/qutebrowser/config.py: -------------------------------------------------------------------------------- 1 | c.auto_save.session = True 2 | c.completion.shrink = True 3 | c.confirm_quit = ["downloads"] 4 | c.content.cache.size = 5242880 5 | c.downloads.location.directory = "~/temp" 6 | c.downloads.location.prompt = False 7 | c.downloads.location.remember = True 8 | c.editor.command = ["emacsclient", "+{line}:{column}", "{}"] 9 | c.hints.scatter = False 10 | c.hints.uppercase = True 11 | c.input.partial_timeout = 2000 12 | c.tabs.tabs_are_windows = True 13 | c.new_instance_open_target = "window" 14 | c.tabs.show = "multiple" 15 | c.window.title_format = "{title}{title_sep}{host}" 16 | ## lazy_restore does not work when idle. 17 | # c.session.lazy_restore = True 18 | c.url.searchengines = { 19 | "DEFAULT": "https://duckduckgo.com/?q={}", 20 | "arch": "http://wiki.archlinux.org/index.php?title=Special%3ASearch&search={}&go=Go", 21 | "aur": "https://aur.archlinux.org/packages.php?O=0&K={}&do_Search=Go", 22 | "ctan": "http://www.ctan.org/search?phrase={}", 23 | "dd": "http://devdocs.io/#q={}", 24 | "edb": "https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;include=subject%3A{};repeatmerged=on;archive=both", 25 | "gd": "https://godoc.org/?q={}", 26 | "gentoo": "https://wiki.gentoo.org/index.php?title=Special%3ASearch&search={}&go=Go", 27 | "gi": "https://www.google.com/search?site=imghp&tbm=isch&source=hp&biw=1676&bih=997&q={}", 28 | "gm": "https://maps.google.com/maps?q={}", 29 | "gp": "http://localhost:6060/pkg/{}", 30 | "gr": "https://www.goodreads.com/search?q={}", 31 | "imdb": "http://www.imdb.com/find?q={}&s=all", 32 | "leo": "http://dict.leo.org/frde/index_de.html#/search={}", 33 | "mba": "http://musicbrainz.org/search?query={}&type=artist&method=indexed", 34 | "mbr": "http://musicbrainz.org/search?query={}&type=release&method=indexed", 35 | "mwr": "http://openmw.readthedocs.io/en/master/search.html?q={}&check_keywords=yes&area=default", 36 | "mww": "https://wiki.openmw.org/index.php?search={}&title=Special%3ASearch&go=Go", 37 | "osm": "https://www.openstreetmap.org/search?query={}", 38 | "so": "http://stackoverflow.com/search?q={}", 39 | "torrent": "https://kickass.unblocked.live/search.php?q={}", 40 | "tpb": "https://ukpirate.click/s/?q={}", 41 | "void": "https://wiki.voidlinux.eu/index.php?search={}&title=Special%3ASearch&go=Go", 42 | "w": "http://en.wikipedia.org/wiki/Special:Search?search={}", 43 | "wb": "http://en.wikibooks.org/wiki/Special:Search?search={}", 44 | "wbf": "http://fr.wikibooks.org/wiki/Special:Search?search={}", 45 | "wf": "http://fr.wikipedia.org/wiki/Special:Search?search={}", 46 | "wk": "http://en.wiktionary.org/wiki/Special:Search?search={}", 47 | "wkf": "http://fr.wiktionary.org/wiki/Special:Search?search={}", 48 | "wks": "http://sv.wiktionary.org/wiki/Special:Search?search={}", 49 | "wine": "http://www.winehq.org/search/?cx=partner-pub-0971840239976722:w9sqbcsxtyf&cof=FORID:10&ie=UTF-8&q={}", 50 | "wr": "http://www.wordreference.com/enfr/{}", 51 | "yt": "http://www.youtube.com/results?search_query={}", 52 | } 53 | 54 | config.bind(',v', 'spawn mpv {url}') 55 | config.bind(',t', 'hint links spawn transmission-auto -a {hint-url}') 56 | config.bind(',T', 'hint -r links spawn transmission-auto -a {hint-url}') 57 | config.bind('yy', 'yank -s') 58 | config.bind('yY', 'yank') 59 | config.bind('yd', 'yank -s domain') 60 | config.bind('yD', 'yank domain') 61 | config.bind('yp', 'yank -s pretty-url') 62 | config.bind('yP', 'yank pretty-url') 63 | config.bind('yt', 'yank -s title') 64 | config.bind('yT', 'yank title') 65 | config.bind('pp', 'open -- {primary}') 66 | config.bind('pP', 'open -- {clipboard}') 67 | config.bind('Pp', 'open -t -- {primary}') 68 | config.bind('PP', 'open -t -- {clipboard}') 69 | config.bind('', 'edit-command', mode='command') 70 | config.bind('', 'completion-item-focus prev-category', mode='command') 71 | config.bind('', 'completion-item-focus next-category', mode='command') 72 | config.bind('', 'completion-item-focus next', mode='command') 73 | config.bind('', 'completion-item-focus prev', mode='command') 74 | config.bind('', 'completion-item-focus prev-category', mode='command') 75 | config.bind('', 'completion-item-focus next-category', mode='command') 76 | 77 | ## Uncomment this to still load settings configured via autoconfig.yml 78 | # config.load_autoconfig() 79 | -------------------------------------------------------------------------------- /.config/ranger/scope.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # ranger supports enhanced previews. If the option "use_preview_script" 3 | # is set to True and this file exists, this script will be called and its 4 | # output is displayed in ranger. ANSI color codes are supported. 5 | 6 | # NOTES: This script is considered a configuration file. If you upgrade 7 | # ranger, it will be left untouched. (You must update it yourself.) 8 | # Also, ranger disables STDIN here, so interactive scripts won't work properly 9 | 10 | # Meanings of exit codes: 11 | # code | meaning | action of ranger 12 | # -----+------------+------------------------------------------- 13 | # 0 | success | success. display stdout as preview 14 | # 1 | no preview | failure. display no preview at all 15 | # 2 | plain text | display the plain content of the file 16 | # 3 | fix width | success. Don't reload when width changes 17 | # 4 | fix height | success. Don't reload when height changes 18 | # 5 | fix both | success. Don't ever reload 19 | # 6 | image | success. display the image $cached points to as an image preview 20 | # 7 | image | success. display the file directly as an image 21 | 22 | # Meaningful aliases for arguments: 23 | path="$1" # Full path of the selected file 24 | width="$2" # Width of the preview pane (number of fitting characters) 25 | height="$3" # Height of the preview pane (number of fitting characters) 26 | cached="$4" # Path that should be used to cache image previews 27 | preview_images="$5" # "True" if image previews are enabled, "False" otherwise. 28 | 29 | maxln=200 # Stop after $maxln lines. Can be used like ls | head -n $maxln 30 | 31 | # Find out something about the file: 32 | mimetype=$(file --mime-type -Lb "$path") 33 | extension=$(/bin/echo "${path##*.}" | awk '{print tolower($0)}') 34 | 35 | # Functions: 36 | # runs a command and saves its output into $output. Useful if you need 37 | # the return value AND want to use the output in a pipe 38 | try() { output=$(eval '"$@"'); } 39 | 40 | # writes the output of the previously used "try" command 41 | dump() { /bin/echo "$output"; } 42 | 43 | # a common post-processing function used after most commands 44 | trim() { head -n "$maxln"; } 45 | 46 | # wraps highlight to treat exit code 141 (killed by SIGPIPE) as success 47 | safepipe() { "$@"; test $? = 0 -o $? = 141; } 48 | 49 | # Image previews, if enabled in ranger. 50 | if [ "$preview_images" = "True" ]; then 51 | case "$mimetype" in 52 | # Image previews for SVG files, disabled by default. 53 | ###image/svg+xml) 54 | ### convert "$path" "$cached" && exit 6 || exit 1;; 55 | # Image previews for image files. w3mimgdisplay will be called for all 56 | # image files (unless overriden as above), but might fail for 57 | # unsupported types. 58 | image/*) 59 | exit 7;; 60 | # Image preview for video, disabled by default.: 61 | ###video/*) 62 | ### ffmpegthumbnailer -i "$path" -o "$cached" -s 0 && exit 6 || exit 1;; 63 | esac 64 | fi 65 | 66 | case "$extension" in 67 | # Archive extensions: 68 | # We ignore compressed tared files as it is too slow. 69 | # bz|bz2|t7z|tbz|tbz2|tgz|tlz|txz|tZ|xz|gz| 70 | a|ace|alz|arc|arj|cab|cpio|deb|jar|lha|lz|lzh|lzma|lzo|\ 71 | rpm|rz|tar|tzo|war|xpi|Z|zip) 72 | try als "$path" && { dump | trim; exit 0; } 73 | try acat "$path" && { dump | trim; exit 3; } 74 | try bsdtar -lf "$path" && { dump | trim; exit 0; } 75 | exit 1;; 76 | rar) 77 | # avoid password prompt by providing empty password 78 | try unrar -p- lt "$path" && { dump | trim; exit 0; } || exit 1;; 79 | 7z) 80 | # avoid password prompt by providing empty password 81 | try 7z -p l "$path" && { dump | trim; exit 0; } || exit 1;; 82 | # PDF documents: 83 | pdf) 84 | try pdftotext -l 10 -nopgbrk -q "$path" - && \ 85 | { dump | trim | fmt -s -w $width; exit 0; } || exit 1;; 86 | # BitTorrent Files 87 | torrent) 88 | try transmission-show "$path" && { dump | trim; exit 5; } || exit 1;; 89 | # ODT Files 90 | odt|ods|odp|sxw) 91 | try odt2txt "$path" && { dump | trim; exit 5; } || exit 1;; 92 | # HTML Pages: 93 | htm|html|xhtml) 94 | try w3m -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; } 95 | try lynx -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; } 96 | try elinks -dump "$path" && { dump | trim | fmt -s -w $width; exit 4; } 97 | ;; # fall back to highlight/cat if the text browsers fail 98 | 99 | ## CUSTOM 100 | mts|m2ts|mkv|ogg) 101 | try mediainfo "$path" && { dump | sed 's/ \+:/: /;' | trim | fmt -s -w $width; exit 4; } ;; 102 | doc) 103 | try antiword "$path" && { dump | trim | fmt -s -w $width; exit 0; } 104 | try catdoc "$path" && { dump | trim | fmt -s -w $width; exit 0; } 105 | exit 1;; 106 | docx) 107 | try docx2txt.pl "$path" - && { dump | trim | fmt -s -w $width; exit 0; } 108 | try catdoc "$path" && { dump | trim | fmt -s -w $width; exit 0; } 109 | exit 1;; 110 | rtf) 111 | try unrtf --text "$path" && { dump | trim | fmt -s -w $width; exit 0; } || exit 1;; 112 | tga) 113 | try mediainfo "$path" && { dump | trim | sed 's/ \+:/: /;'; exit 5; } || exit 1;; 114 | esac 115 | 116 | case "$mimetype" in 117 | # Syntax highlight for text files: 118 | text/* | */xml) 119 | if [ "$(tput colors)" -ge 256 ]; then 120 | pygmentize_format=terminal256 121 | highlight_format=xterm256 122 | else 123 | pygmentize_format=terminal 124 | highlight_format=ansi 125 | fi 126 | try safepipe highlight --out-format=${highlight_format} "$path" && { dump | trim; exit 5; } 127 | try safepipe pygmentize -f ${pygmentize_format} "$path" && { dump | trim; exit 5; } 128 | exit 2;; 129 | # Ascii-previews of images: 130 | image/*) 131 | exiftool "$path" && exit 5 132 | img2txt --gamma=0.6 --width="$width" "$path" && exit 4 || exit 1;; 133 | # Display information about media files: 134 | video/* | audio/*) 135 | # Use sed to remove spaces so the output fits into the narrow window 136 | try mediainfo "$path" && { dump | trim | sed 's/ \+:/: /;'; exit 5; } || exit 1 137 | exiftool "$path" && exit 5;; 138 | esac 139 | 140 | exit 1 141 | -------------------------------------------------------------------------------- /.config/sxiv/exec/image-info: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | filename=$(basename "$1") 4 | filesize=$(du -Hh "$1" | cut -f 1) 5 | 6 | ## The '[0]' stands for the first frame of a multi-frame file, e.g. gif. 7 | geometry=$(identify -format '%wx%h' "$1[0]") 8 | 9 | printf "%s | %s | %s" "$filename" "$filesize" "$geometry" 10 | -------------------------------------------------------------------------------- /.config/sxiv/exec/key-handler: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | readonly KEY="$1" 4 | 5 | orient() { 6 | while read file; do 7 | mogrify -auto-orient "$file" 8 | done 9 | } 10 | 11 | rotate() { 12 | degree="$1" 13 | while read file; do 14 | case "$(file -b -i "$file")" in 15 | image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;; 16 | *) mogrify -rotate "$degree" "$file" ;; 17 | esac 18 | done 19 | } 20 | 21 | case "$KEY" in 22 | "C-c") tr '\n' ' ' | xsel -i ;; 23 | "C-e") while read file; do urxvt -bg "#444" -fg "#eee" -sl 0 -title "$file" -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;; 24 | "C-g") tr '\n' '\0' | xargs -0 gimp & ;; 25 | "C-o") orient ;; 26 | "C-comma") rotate 270 ;; 27 | "C-period") rotate 90 ;; 28 | "C-slash") rotate 180 ;; 29 | "C-d") while read file; do trash "$file"; done ;; 30 | esac 31 | -------------------------------------------------------------------------------- /.config/transmission-daemon/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "alt-speed-down": 50, 3 | "alt-speed-enabled": false, 4 | "alt-speed-time-begin": 540, 5 | "alt-speed-time-day": 127, 6 | "alt-speed-time-enabled": false, 7 | "alt-speed-time-end": 1020, 8 | "alt-speed-up": 50, 9 | "bind-address-ipv4": "0.0.0.0", 10 | "bind-address-ipv6": "::", 11 | "blocklist-enabled": false, 12 | "blocklist-url": "http://www.example.com/blocklist", 13 | "cache-size-mb": 4, 14 | "dht-enabled": true, 15 | "download-dir": "/home/ambrevar/temp", 16 | "download-queue-enabled": true, 17 | "download-queue-size": 5, 18 | "encryption": 1, 19 | "idle-seeding-limit": 30, 20 | "idle-seeding-limit-enabled": false, 21 | "incomplete-dir": "/home/ambrevar/temp", 22 | "incomplete-dir-enabled": false, 23 | "lpd-enabled": false, 24 | "message-level": 2, 25 | "peer-congestion-algorithm": "", 26 | "peer-id-ttl-hours": 6, 27 | "peer-limit-global": 200, 28 | "peer-limit-per-torrent": 50, 29 | "peer-port": 51413, 30 | "peer-port-random-high": 65535, 31 | "peer-port-random-low": 49152, 32 | "peer-port-random-on-start": false, 33 | "peer-socket-tos": "default", 34 | "pex-enabled": true, 35 | "port-forwarding-enabled": true, 36 | "preallocation": 1, 37 | "prefetch-enabled": true, 38 | "queue-stalled-enabled": true, 39 | "queue-stalled-minutes": 30, 40 | "ratio-limit": 2, 41 | "ratio-limit-enabled": false, 42 | "rename-partial-files": true, 43 | "rpc-authentication-required": false, 44 | "rpc-bind-address": "0.0.0.0", 45 | "rpc-enabled": true, 46 | "rpc-host-whitelist": "", 47 | "rpc-host-whitelist-enabled": true, 48 | "rpc-password": "{4f22e3fd96f7a735dda8aab9dcf21f1f2db83236WtWd032x", 49 | "rpc-port": 9091, 50 | "rpc-url": "/transmission/", 51 | "rpc-username": "", 52 | "rpc-whitelist": "127.0.0.1", 53 | "rpc-whitelist-enabled": true, 54 | "scrape-paused-torrents-enabled": true, 55 | "script-torrent-done-enabled": false, 56 | "script-torrent-done-filename": "", 57 | "seed-queue-enabled": false, 58 | "seed-queue-size": 10, 59 | "speed-limit-down": 100, 60 | "speed-limit-down-enabled": false, 61 | "speed-limit-up": 100, 62 | "speed-limit-up-enabled": false, 63 | "start-added-torrents": true, 64 | "trash-original-torrent-files": true, 65 | "umask": 18, 66 | "upload-slots-per-torrent": 14, 67 | "utp-enabled": true, 68 | "watch-dir": "/home/ambrevar/temp", 69 | "watch-dir-enabled": true 70 | } 71 | -------------------------------------------------------------------------------- /.conkyrc: -------------------------------------------------------------------------------- 1 | -- -*- mode: lua; -*- 2 | 3 | conky.config = { 4 | out_to_x = false, 5 | background = false, 6 | cpu_avg_samples = 2, 7 | net_avg_samples = 2, 8 | no_buffers = true, 9 | out_to_console = true, 10 | out_to_stderr = false, 11 | extra_newline = false, 12 | update_interval = 1.0, 13 | uppercase = false, 14 | use_spacer = left, 15 | times_in_seconds = true, 16 | }; 17 | 18 | -- Colors are in dzen2 format. 19 | conky.text = 20 | [[^fg(grey)${time %a %d %b %R} \ 21 | \ 22 | ^fg(grey)CPU:^fg(DeepSkyBlue)$cpu% \ 23 | ^fg(grey)RAM:^fg(DeepSkyBlue)${if_match ${to_bytes $memeasyfree} < 536870912}^fg(Red)${endif}$memperc% \ 24 | ^fg(grey)↓^fg(DeepSkyBlue)${eval $${downspeedf ${gw_iface}}} \ 25 | ^fg(grey)↑^fg(DeepSkyBlue)${upspeedf wlp2s0} \ 26 | ${if_match "${exec pactl list sinks | awk '/^\tMute:/ {print $2;exit}'}" == "no"}^fg(grey)♪^fg(DeepSkyBlue)${exec pactl list sinks | awk '/^\tVolume:/ {print $5;exit}'}${endif} \ 27 | ${if_existing .mu/}^fg(grey)✉^fg(DeepSkyBlue)${execi 30 mu find --nocolor --sortfield=d --maxnum=500 flag:unread AND NOT flag:trashed 2>/dev/null | wc -l} ${endif}\ 28 | ${if_match $battery_percent != 0}^fg(grey)⚡^fg(DeepSkyBlue)${if_match ${battery_time} <= 600}^fg(Red)${endif}${battery_short}: ${format_time ${battery_time} "(\dd )(\hh )\mmin"} ${endif}\ 29 | ${if_match ${to_bytes ${diskio nvme0n1}} > 1048576}^fg(grey)nvme0n1:^fg(DeepSkyBlue)${diskio nvme0n1}${endif} \ 30 | ${if_match ${to_bytes ${diskio sda}} > 1048576}^fg(grey)sda:^fg(DeepSkyBlue)${diskio sda}${endif} \ 31 | ${if_match ${to_bytes ${diskio sdb}} > 1048576}^fg(grey)sdb:^fg(DeepSkyBlue)${diskio sdb}${endif} \ 32 | ${if_match ${to_bytes ${diskio sdc}} > 1048576}^fg(grey)sdc:^fg(DeepSkyBlue)${diskio sdc}${endif} \ 33 | ${if_match ${to_bytes ${fs_free /}} < 1073741824}^fg(grey)/:^fg(Red)${fs_free /}${endif} \ 34 | ${if_match ${to_bytes ${fs_free /home}} < 1073741824}^fg(grey)/home:^fg(Red)${fs_free /home}${endif} \ 35 | ]] 36 | 37 | -- TODO: Emms current track: 38 | -- ${if_match "${execi 5 emacsclient -e '(and (fboundp (quote emms-playlist-current-selected-track)) (emms-playlist-current-selected-track) (emms-track-description (emms-playlist-current-selected-track)))'}" != "nil"}^fg(grey)♪^fg(DeepSkyBlue)${execi 5 emacsclient -e '(emms-track-description (emms-playlist-current-selected-track))' | tr -d '"'}${endif} \ 39 | -- Above line works but polling interferes with bindings (Emacs echoes '' on keypresses). 40 | 41 | -- TODO: Unread mail with native 'new_mails' does not seem to support totals. 42 | -- TODO: Change color when e-mails are not 0? 43 | -- TODO: Conditional display of network, sound. 44 | -- Probably need $lua+$eval for most of the TODOs. 45 | -- TODO: Calling pactl when pulseaudio is not running will fire it up, which can 46 | -- lead to a race condition when relogging: 4 pulseaudio processes will end up 47 | -- running. 48 | -------------------------------------------------------------------------------- /.emacs.d/.dir-locals.el: -------------------------------------------------------------------------------- 1 | ((nil . ((ambrevar/prettify-inhibit-p . nil)))) 2 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-bbcode.el: -------------------------------------------------------------------------------- 1 | ;;; BBcode 2 | 3 | ;;; For new tags use `bbcode/make-key-binding'. 4 | (define-key bbcode-mode-map (kbd "M-") 'bbcode/insert-tag-*) 5 | 6 | (font-lock-add-keywords nil `((,(bbcode/make-tag-regex "h") . 'font-lock-builtin-face))) 7 | (font-lock-add-keywords nil `((,(bbcode/make-tag-regex "\\*") . 'font-lock-string-face))) 8 | 9 | (provide 'init-bbcode) 10 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-dired.el: -------------------------------------------------------------------------------- 1 | ;;; Dired 2 | ;;; WARNING: This file is loaded unconditionally on startup. 3 | ;;; We cannot assume that current buffer is in dired-mode. 4 | 5 | (ambrevar/define-keys dired-mode-map 6 | "C-c h" 'ambrevar/dired-toggle-humansize 7 | "" 'dired-up-directory 8 | "" 'dired-find-file 9 | "SPC" 'dired-mark 10 | "" 'dired-up-directory 11 | "b" 'dired-up-directory) 12 | 13 | (when (require 'dired+ nil t) 14 | (toggle-diredp-find-file-reuse-dir 1)) 15 | 16 | ;;; On a GNU system, ls has the option to sort folders first. 17 | (if (string-match "^gnu.*" (prin1-to-string system-type)) 18 | (setq dired-listing-switches "--group-directories-first -lha") 19 | (setq dired-listing-switches "-lha")) 20 | 21 | ;;; Switches are set before the hook is called, so we need to reload dired. The 22 | ;;; dired-internal-noselect is a lower level function, so it is faster. WARNING: 23 | ;;; Not sure if it is equivalent though. 24 | ;; (dired dired-directory dired-listing-switches) 25 | (defun ambrevar/dired-set-listing-switches () 26 | (dired-internal-noselect dired-directory dired-listing-switches)) 27 | 28 | (setq wdired-allow-to-change-permissions t) 29 | 30 | ;;; omit-mode needs to be started _after_ omit-files redefinition. 31 | (require 'dired-x) 32 | (setq dired-omit-files "^\\.") 33 | 34 | (setq dired-guess-shell-alist-user 35 | (list 36 | '("\\.ogg$" "mpv") 37 | '("\\.\\(jpe?g\\|png\\|git\\)$" "sxiv") 38 | '("\\.\\(mkv\\|mpe?g\\|avi\\|mp4\\|ogm\\)$" "mpv"))) 39 | 40 | (defvar ambrevar/dired-showing-humansize t "If dired is displaying humansize or not.") 41 | 42 | (defun ambrevar/dired-toggle-humansize () 43 | "Toggle displaying humansize in dired." 44 | (interactive) 45 | (let ((switch-regexp "\\(\\`\\| \\)-\\([a-gi-zA-Z]*\\)\\(h\\)\\([^ ]*\\)") 46 | case-fold-search) 47 | (while (string-match switch-regexp dired-actual-switches) 48 | (if (and (equal (match-string 2 dired-actual-switches) "") 49 | (equal (match-string 4 dired-actual-switches) "")) 50 | (setq dired-actual-switches 51 | (replace-match "" t t dired-actual-switches)) 52 | (setq dired-actual-switches 53 | (replace-match "" t t dired-actual-switches 3)))) 54 | (if ambrevar/dired-showing-humansize 55 | (setq ambrevar/dired-showing-humansize nil) 56 | (progn 57 | (setq dired-actual-switches 58 | (concat dired-actual-switches 59 | (if (string-match-p "\\`-[[:alnum:]]+\\'" 60 | dired-actual-switches) 61 | "h" " -h"))) 62 | (setq ambrevar/dired-showing-humansize t)))) 63 | (revert-buffer)) 64 | 65 | (dolist (fun '(dired-omit-mode ambrevar/dired-set-listing-switches)) 66 | (add-hook 'dired-mode-hook fun)) 67 | 68 | (provide 'init-dired) 69 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-elfeed.el: -------------------------------------------------------------------------------- 1 | ;;; Elfeed 2 | 3 | (setq elfeed-db-directory (expand-file-name "elfeed" user-emacs-directory)) 4 | 5 | (defun ambrevar/elfeed-play-with-mpv () 6 | "Play entry link with mpv." 7 | (interactive) 8 | (let ((entry (if (eq major-mode 'elfeed-show-mode) elfeed-show-entry (elfeed-search-selected :single))) 9 | (quality-arg "") 10 | (quality-val (completing-read "Max height resolution (0 for unlimited): " '("0" "480" "720") nil nil))) 11 | (setq quality-val (string-to-number quality-val)) 12 | (message "Opening %s with height≤%s with mpv..." (elfeed-entry-link entry) quality-val) 13 | (when (< 0 quality-val) 14 | (setq quality-arg (format "--ytdl-format=[height<=?%s]" quality-val))) 15 | (start-process "elfeed-mpv" nil "mpv" quality-arg (elfeed-entry-link entry)))) 16 | 17 | (defun ambrevar/elfeed-open-with-eww () 18 | "Open in eww with `eww-readable'." 19 | (interactive) 20 | (let ((entry (if (eq major-mode 'elfeed-show-mode) elfeed-show-entry (elfeed-search-selected :single)))) 21 | (eww (elfeed-entry-link entry)) 22 | (add-hook 'eww-after-render-hook 'eww-readable nil t))) 23 | 24 | (defvar ambrevar/elfeed-visit-patterns 25 | '(("youtu\\.?be" . ambrevar/elfeed-play-with-mpv) 26 | ("phoronix" . ambrevar/elfeed-open-with-eww)) 27 | "List of (regexps . function) to match against elfeed entry link to know 28 | whether how to visit the link.") 29 | 30 | (defun ambrevar/elfeed-visit-maybe-external () 31 | "Visit with external function if entry link matches `ambrevar/elfeed-visit-patterns', 32 | visit otherwise." 33 | (interactive) 34 | (let ((entry (if (eq major-mode 'elfeed-show-mode) 35 | elfeed-show-entry 36 | (elfeed-search-selected :single))) 37 | (patterns ambrevar/elfeed-visit-patterns)) 38 | (while (and patterns (not (string-match (caar patterns) (elfeed-entry-link entry)))) 39 | (setq patterns (cdr patterns))) 40 | (cond 41 | (patterns 42 | (funcall (cdar patterns))) 43 | ((eq major-mode 'elfeed-search-mode) 44 | (call-interactively 'elfeed-search-show-entry)) 45 | (t (elfeed-show-visit))))) 46 | 47 | (define-key elfeed-search-mode-map "v" #'elfeed-play-in-mpv) 48 | 49 | (defun ambrevar/elfeed-kill-entry () 50 | "Like `elfeed-kill-buffer' but pop elfeed search." 51 | (interactive) 52 | (elfeed-kill-buffer) 53 | (switch-to-buffer "*elfeed-search*")) 54 | (define-key elfeed-show-mode-map "q" #'ambrevar/elfeed-kill-entry) 55 | 56 | (defun ambrevar/elfeed-switch-back () 57 | "Back to the last elfeed buffer, entry or search." 58 | (interactive) 59 | (let ((buffer (get-buffer "*elfeed-entry*"))) 60 | (if buffer 61 | (switch-to-buffer buffer) 62 | (elfeed)))) 63 | 64 | (load "~/personal/news/elfeed.el" t) 65 | 66 | (provide 'init-elfeed) 67 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-emms.el: -------------------------------------------------------------------------------- 1 | ;;; Emms 2 | 3 | ;;; TODO: See if mpd is faster at building the db. Not so important. 4 | ;;; TODO: Change face from purple to white? 5 | ;;; TODO: emms-all causes some "require"d files to be loaded twice if called after, say, emms-browser was loaded. 6 | (emms-all) 7 | (emms-history-load) 8 | 9 | (setq emms-player-list (list emms-player-mpv) 10 | emms-source-file-default-directory (expand-file-name "~/music") 11 | emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find 12 | ;; Cover thumbnails. 13 | emms-browser-covers 'emms-browser-cache-thumbnail) 14 | (add-to-list 'emms-player-mpv-parameters "--no-audio-display") 15 | (add-to-list 'emms-info-functions 'emms-info-cueinfo) 16 | 17 | (if (executable-find "emms-print-metadata") 18 | (progn 19 | (require 'emms-info-libtag) 20 | (add-to-list 'emms-info-functions 'emms-info-libtag) 21 | (delete 'emms-info-ogginfo emms-info-functions) 22 | (delete 'emms-info-mp3info emms-info-functions)) 23 | (add-to-list 'emms-info-functions 'emms-info-ogginfo) 24 | (add-to-list 'emms-info-functions 'emms-info-mp3info)) 25 | 26 | ;;; Resume on restart. 27 | ;;; We don't use bookmarks as that could interfere with user's ones. 28 | (with-eval-after-load 'desktop 29 | (add-to-list 'desktop-globals-to-save 'emms-playing-time) 30 | (when (emms-playlist-current-selected-track) 31 | (let ((time emms-playing-time)) 32 | (setq emms-playing-time 0) ; Don't disturb the time display. 33 | (and (memq 'emms-player-mpv emms-player-list) 34 | (executable-find "mpv") 35 | (push "--mute=yes" emms-player-mpv-parameters)) 36 | (emms-start) 37 | (sleep-for 0 300) ; This is required for the player might not be ready yet. 38 | ;; TODO: This 'sleep-for' is a kludge and upstream should provide a provision for it. 39 | (with-demoted-errors "EMMS error: %S" (emms-player-seek-to time)) 40 | (and (memq 'emms-player-mpv emms-player-list) 41 | (executable-find "mpv") 42 | (pop emms-player-mpv-parameters) 43 | ;; TODO: Adapt this to simple-mpv. 44 | (call-process-shell-command (emms-player-mpv--format-command "mute") nil nil nil)) 45 | (emms-pause)))) 46 | 47 | (when (require 'helm-emms nil t) 48 | (setq helm-emms-default-sources 49 | '(helm-source-emms-dired 50 | helm-source-emms-files ; Disable for a huge speed-up. 51 | helm-source-emms-streams))) 52 | 53 | (defun ambrevar/emms-play-on-add (old-pos) 54 | "Play tracks when calling `emms-browser-add-tracks' if nothing 55 | is currently playing." 56 | (interactive) 57 | (when (or (not emms-player-playing-p) 58 | emms-player-paused-p 59 | emms-player-stopped-p) 60 | (with-current-emms-playlist 61 | (goto-char old-pos) 62 | ;; if we're sitting on a group name, move forward 63 | (unless (emms-playlist-track-at (point)) 64 | (emms-playlist-next)) 65 | (emms-playlist-select (point))) 66 | (emms-stop) 67 | (emms-start))) 68 | (add-hook 'emms-browser-tracks-added-hook 'ambrevar/emms-play-on-add) 69 | 70 | ;;; Display album in playlist 71 | (defun ambrevar/emms-artist-album-track-and-title-format (bdata fmt) 72 | (concat 73 | "%i" 74 | (let ((artist (emms-browser-format-elem fmt "a"))) 75 | (if (not artist) 76 | "%n" ; If unknown, display the filename. 77 | (concat 78 | "%a - " 79 | (let ((album (emms-browser-format-elem fmt "A"))) 80 | (if album "%A - " "")) 81 | (let ((disc (emms-browser-format-elem fmt "D"))) 82 | (if (and disc (not (string= disc ""))) "%D/" "")) 83 | (let ((track (emms-browser-format-elem fmt "T"))) 84 | (if (and track (not (string= track "0"))) 85 | "%T. " 86 | "")) 87 | "%t [%d]"))))) 88 | (setq emms-browser-playlist-info-title-format 'ambrevar/emms-artist-album-track-and-title-format) 89 | ;; Display disc number in browser 90 | (defun ambrevar/emms-browser-track-artist-and-title-format (bdata fmt) 91 | (concat 92 | "%i" 93 | (let ((disc (emms-browser-format-elem fmt "D"))) 94 | (if (and disc (not (string= disc ""))) 95 | "%D/")) 96 | (let ((track (emms-browser-format-elem fmt "T"))) 97 | (if (and track (not (string= track "0"))) 98 | "%T. " 99 | "")) 100 | "%n")) 101 | (setq emms-browser-info-title-format 'ambrevar/emms-browser-track-artist-and-title-format) 102 | 103 | (provide 'init-emms) 104 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-engine.el: -------------------------------------------------------------------------------- 1 | ;;; Engine mode 2 | 3 | (engine-mode) 4 | (require 'eww) 5 | 6 | (defun ambrevar/engine-eww-function (url &optional _) 7 | (interactive) 8 | (eww url)) 9 | 10 | (defengine arch-aur 11 | "https://aur.archlinux.org/packages.php?O=0&K=%s&do_Search=Go" 12 | :keybinding "aa") 13 | 14 | (defengine arch-packages 15 | "https://www.archlinux.org/packages/?sort=&q=%s&maintainer=&flagged=" 16 | :keybinding "ap") 17 | 18 | (defengine arch-wiki 19 | "http://wiki.archlinux.org/index.php?title=Special%%3ASearch&search=%s&go=Go" 20 | :keybinding "aw" 21 | :browser 'ambrevar/engine-eww-function) 22 | 23 | (defengine ctan 24 | "http://www.ctan.org/search?phrase=%s" 25 | :keybinding "c") 26 | 27 | (defengine devdocs 28 | "http://devdocs.io/#q=%s" 29 | :keybinding "dd") 30 | 31 | (defengine duckduckgo 32 | "https://duckduckgo.com/?q=%s" 33 | :keybinding "dg") 34 | 35 | (defengine emacs-debbugs 36 | "https://debbugs.gnu.org/cgi/pkgreport.cgi?package=emacs;include=subject%3A%s;repeatmerged=on;archive=both" 37 | :keybinding "eb" 38 | :browser 'ambrevar/engine-eww-function) 39 | 40 | (defengine emacs-devel 41 | "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emacs-devel&submit=Search&query=%s" 42 | :keybinding "ed" 43 | :browser 'ambrevar/engine-eww-function) 44 | 45 | (defengine emms-help 46 | "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=emms-help&submit=Search!&query=%s" 47 | :keybinding "ee" 48 | :browser 'ambrevar/engine-eww-function) 49 | 50 | (defengine gentoo 51 | "https://wiki.gentoo.org/index.php?title=Special%3ASearch&search=%s&go=Go" 52 | :keybinding "ge") 53 | 54 | (defengine github 55 | "https://github.com/search?ref=simplesearch&q=%s" 56 | :keybinding "gh") 57 | 58 | (defengine goodreads 59 | "https://www.goodreads.com/search?q=%s" 60 | :keybinding "gr") 61 | 62 | (defengine google-maps 63 | "https://maps.google.com/maps?q=%s" 64 | :keybinding "gm") 65 | 66 | (defengine guix-devel 67 | "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=guix-devel&submit=Search&query=%s" 68 | :keybinding "gud" 69 | :browser 'ambrevar/engine-eww-function) 70 | 71 | (defengine guix-help 72 | "https://lists.gnu.org/archive/cgi-bin/namazu.cgi?idxname=help-guix&submit=Search!&query=%s" 73 | :keybinding "guh" 74 | :browser 'ambrevar/engine-eww-function) 75 | 76 | (defengine imdb 77 | "http://www.imdb.com/find?q=%s&s=all" 78 | :keybinding "i") 79 | 80 | (defengine musicbrainz 81 | "http://musicbrainz.org/search?query=%s&type=artist&method=indexed" 82 | :keybinding "mb") 83 | 84 | (defengine openstreetmap 85 | "https://www.openstreetmap.org/search?query=%s" 86 | :keybinding "osm") 87 | 88 | (defengine stackoverflow 89 | "http://stackoverflow.com/search?q=%s" 90 | :keybinding "s") 91 | 92 | (defengine torrent-kickass 93 | "https://kickass.unblocked.live/search.php?q=%s" 94 | :keybinding "tk") 95 | 96 | (defengine torrent-piratebay 97 | "https://ukpirate.click/s/?q=%s" 98 | :keybinding "tp") 99 | 100 | (defengine wikipedia 101 | "http://www.wikipedia.org/search-redirect.php?language=en&go=Go&search=%s" 102 | :keybinding "wp" 103 | :docstring "Search Wikipedia!") 104 | 105 | (defengine wikibooks 106 | "http://en.wikibooks.org/wiki/Special:Search?search=%s" 107 | :keybinding "wb") 108 | 109 | (defengine wiktionary 110 | "http://en.wiktionary.org/wiki/Special:Search?search=%s" 111 | :keybinding "wk") 112 | 113 | (defengine wine-appdb 114 | "http://www.winehq.org/search/?q=%s" 115 | :keybinding "wk") 116 | 117 | (defengine youtube 118 | "http://www.youtube.com/results?search_query=%s" 119 | :keybinding "y") 120 | 121 | (load "~/personal/bookmarks/engines.el" t) 122 | 123 | (provide 'init-engine) 124 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-evil-gnus.el: -------------------------------------------------------------------------------- 1 | ;;; Evil+Gnus 2 | 3 | (evil-set-initial-state 'gnus-summary-mode 'motion) 4 | (evil-define-key 'motion gnus-summary-mode-map 5 | ;; motion 6 | (kbd "") 'gnus-summary-widget-forward 7 | (kbd "") 'gnus-summary-widget-backward 8 | (kbd "") 'gnus-summary-prev-page 9 | (kbd "S-SPC") 'gnus-summary-prev-page 10 | (kbd "SPC") 'gnus-summary-next-page 11 | (kbd "") 'gnus-summary-scroll-up ; TODO: bad binding? 12 | "]" 'gnus-summary-next-article 13 | "[" 'gnus-summary-prev-article 14 | (kbd "C-j") 'gnus-summary-next-article 15 | (kbd "C-k") 'gnus-summary-prev-article 16 | 17 | "zz" 'gnus-recenter 18 | "z#" 'gnus-summary-mark-as-processable 19 | "!" 'gnus-summary-execute-command 20 | "zc" 'gnus-cache-enter-article 21 | "gb" 'gnus-summary-best-unread-article 22 | "gf" 'gnus-summary-first-unread-article 23 | "z/" 'gnus-summary-limit-map 24 | ;; "<" "=" ">" ... 25 | "zd" 'gnus-summary-mark-as-dormant 26 | ;; "gA" 27 | ;; "gB" 28 | ;; "zC" 29 | ;; "zD" 30 | ;; "zE" 31 | ;; "zF" 32 | ;; "gG" 33 | ;; "gH" 34 | ;; "zI" 35 | ;; "gK" 36 | ;; "zL" 37 | ;; "gM" 38 | 39 | "r" 'gnus-summary-reply 40 | "R" 'gnus-summary-reply-with-original 41 | 42 | "gO" 'gnus-summary-save-map 43 | "gS" 'gnus-summary-send-map 44 | "gT" 'gnus-summary-thread-map 45 | "gV" 'gnus-summary-score-map 46 | "gW" 'gnus-summary-wash-map 47 | "X" 'gnus-uu-extract-map 48 | "gY" 'gnus-summary-buffer-map 49 | "gZ" 'gnus-summary-exit-map 50 | "z^" 'gnus-summary-refer-parent-article 51 | ;; "a" ... 52 | "zt" 'gnus-summary-toggle-header 53 | "u" 'gnus-summary-tick-article-forward 54 | "U" 'gnus-summary-tick-article-backward 55 | "x" 'gnus-summary-limit-to-unread 56 | "zp" 'gnus-summary-pipe-output 57 | 58 | ;; filter 59 | "s" 'gnus-summary-isearch-article 60 | 61 | ;; quit 62 | "Q" 'gnus-summary-exit-no-update 63 | "q" 'gnus-summary-exit 64 | "ZQ" 'gnus-summary-exit-no-update 65 | "ZZ" 'gnus-summary-exit) 66 | 67 | (evil-set-initial-state 'gnus-article-mode 'motion) 68 | 69 | (provide 'init-evil-gnus) 70 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-flycheck.el: -------------------------------------------------------------------------------- 1 | ;;; Flycheck 2 | 3 | (defun ambrevar/flycheck-and-whitespace-mode () 4 | "Toggle `flycheck-mode' and `whitespace-mode'." 5 | (interactive) 6 | (if (derived-mode-p 'text-mode) 7 | (flyspell-mode) 8 | (flycheck-mode 'toggle) 9 | (if flyspell-mode (flyspell-mode 0) (flyspell-prog-mode))) 10 | (whitespace-mode 'toggle)) 11 | (global-set-key (kbd "") 'ambrevar/flycheck-and-whitespace-mode) 12 | 13 | (define-key flycheck-mode-map (kbd "C-c ! h") 'helm-flycheck) 14 | 15 | (provide 'init-flycheck) 16 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-go.el: -------------------------------------------------------------------------------- 1 | ;;; Go 2 | 3 | ;;; REVIEW: We should not need to use `use-local-map' here. 4 | ;;; Reported at https://github.com/dominikh/go-mode.el/issues/191. 5 | (use-local-map go-mode-map) 6 | 7 | (ambrevar/local-set-keys 8 | "C-c m" 'ambrevar/go-main 9 | "C-c D" 'godoc 10 | "C-c d" 'godoc-at-point 11 | "M-." #'godef-jump 12 | "" 'ambrevar/go-metalinter 13 | "C-" 'ambrevar/go-metalinter-command) 14 | (when (require 'helm-go-package nil t) 15 | (local-set-key (kbd "C-c D") 'helm-go-package)) 16 | 17 | (when (require 'company-go nil t) 18 | (add-hook 'go-mode-hook 'company-mode) 19 | (add-to-list 'company-backends 'company-go) 20 | (local-set-key (kbd "M-") (if (require 'helm-company nil t) 'helm-company 'company-complete))) 21 | 22 | (setq gofmt-command "goimports") 23 | (setq godoc-command "godoc -ex") 24 | (setq godoc-and-godef-command "godoc -ex") 25 | 26 | (defvar-local ambrevar/gometalinter-args 27 | (mapconcat 28 | 'identity 29 | '("--cyclo-over=20 --deadline=20s" 30 | ;; Ignore some benign errors. 31 | "-e 'declaration of \"?err\"? shadows'" 32 | "-e 'error return value not checked \\(.*\\.Close\\(\\)'" 33 | ;; Customize linters. 34 | "-E misspell" 35 | "-E unparam" 36 | "-E unused" 37 | ;; gofmt is only useful if not called on save with '-s' 38 | ;; (goimports does not do this) and for its first rule not 39 | ;; superseded by gosimple or solint: 40 | ;; https://golang.org/cmd/gofmt/#hdr-The_simplify_command 41 | "-E gofmt") 42 | " ") "Additional arguments to pass to gometalinter.") 43 | 44 | (defun ambrevar/go-metalinter (arg) 45 | "Run gometalinter. 46 | With prefix argument, prompt for commandline." 47 | (interactive "P") 48 | (let ((compile-command (format "gometalinter %s" ambrevar/gometalinter-args))) 49 | (if arg 50 | (call-interactively 'compile) 51 | (compile compile-command)))) 52 | 53 | (defun ambrevar/go-metalinter-command () 54 | "Prompt for gometalinter commandline and run it." 55 | (interactive) 56 | (ambrevar/go-metalinter t)) 57 | 58 | (defun ambrevar/go-set-compile-command () 59 | "Set `compile-command' depending on the context. 60 | 61 | - go install: file is in GOPATH and is not a test file. 62 | - go test: file is in GOPATH and is a test file. 63 | - go run `buffer-file-name': file is not in GOPATH. 64 | 65 | Note that the -cover test flag is left out since it shifts line numbers." 66 | (interactive) 67 | (setq compile-command 68 | (if (ambrevar/go-buffer-in-gopath-p) 69 | (if (string-match "_test.[gG][oO]$" buffer-file-name) 70 | "go test -v -run ." 71 | "go install") 72 | (concat "go run " (shell-quote-argument buffer-file-name))))) 73 | 74 | (defun ambrevar/go-buffer-in-gopath-p () 75 | (if (not buffer-file-name) 76 | nil 77 | (let ((dir (expand-file-name (file-name-directory buffer-file-name))) (looping t) (gopath (split-string (getenv "GOPATH") ":"))) 78 | (while (progn 79 | (if (member dir gopath) 80 | (setq looping nil) 81 | (setq dir (expand-file-name ".." dir))) 82 | (and looping (not (string= dir "/"))))) 83 | (if (string= dir "/") nil t)))) 84 | 85 | (when (require 'go-guru nil t) 86 | (unless (executable-find "guru") 87 | ;; Requires `call-process-to-string' from `functions'." 88 | (require 'functions) 89 | (setq go-guru-command 90 | (concat (replace-regexp-in-string "\n$" "" (ambrevar/call-process-to-string "go" "env" "GOTOOLDIR")) "/guru")))) 91 | 92 | (defun ambrevar/go-turn-on-gofmt-before-save () 93 | (add-hook 'before-save-hook #'gofmt-before-save nil t)) 94 | 95 | (add-hook 'go-mode-hook 'ambrevar/go-turn-on-gofmt-before-save) 96 | 97 | (when (require 'go-eldoc nil t) 98 | (add-hook 'go-mode-hook 'go-eldoc-setup)) 99 | 100 | (add-hook 'go-mode-hook 'ambrevar/go-set-compile-command) 101 | 102 | (defun ambrevar/godoc-setup () 103 | (setq tab-width 8)) 104 | 105 | (add-hook 'godoc-mode-hook 'ambrevar/godoc-setup) 106 | 107 | (define-skeleton ambrevar/go-main 108 | "Insert main function with basic includes." 109 | nil 110 | > "package main" "\n" \n 111 | "import (" \n 112 | "\"fmt\"" \n 113 | ")" > "\n" \n 114 | "func main() {" \n 115 | > @ _ \n 116 | "}" > \n) 117 | 118 | (provide 'init-go) 119 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-gud.el: -------------------------------------------------------------------------------- 1 | ;;; GUD 2 | 3 | ;;; Set GUD to display many windows by default. 4 | (setq gdb-many-windows t) 5 | 6 | ;;; Change GUD many-windows layout. 7 | (defun gdb-setup-windows () 8 | "Layout the window pattern for `gdb-many-windows'. 9 | Do not set `gdb-show-main' to true as we handle it manually here." 10 | (setq gdb-source-window (selected-window)) 11 | (gdb-display-locals-buffer) 12 | (delete-other-windows) 13 | (gdb-display-stack-buffer) 14 | (delete-other-windows) 15 | (gdb-display-breakpoints-buffer) 16 | (delete-other-windows) 17 | 18 | (switch-to-buffer 19 | (if gud-last-last-frame 20 | (gud-find-file (car gud-last-last-frame)) 21 | (if gdb-main-file 22 | (gud-find-file gdb-main-file) 23 | ;; Put buffer list in window if we can't find a source file. 24 | (list-buffers-noselect)))) 25 | 26 | (split-window-horizontally) 27 | (other-window 1) 28 | (split-window nil (/ ( * (window-height) 3) 4)) 29 | (split-window nil (/ (window-height) 3)) 30 | (gdb-set-window-buffer (gdb-locals-buffer-name)) 31 | 32 | (split-window-horizontally) 33 | (other-window 1) 34 | (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-inferior-io)) 35 | 36 | (other-window 1) 37 | (gdb-set-window-buffer gud-comint-buffer) 38 | (other-window 1) 39 | (gdb-set-window-buffer (gdb-stack-buffer-name)) 40 | (split-window-horizontally) 41 | (other-window 1) 42 | (gdb-set-window-buffer (gdb-breakpoints-buffer-name)) 43 | (other-window 1)) 44 | 45 | (provide 'init-gud) 46 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-lisp.el: -------------------------------------------------------------------------------- 1 | ;;; Lisp 2 | 3 | (with-eval-after-load 'lispyville 4 | ;; REVIEW: lispy-occur: helm-occur does not restrict to region. Check latest helm. 5 | (lispyville-set-key-theme 6 | '(operators ; Add equivalent for lispy-delete? 7 | c-w ; Bind M-backspace to lispyville-delete-backward-word? 8 | (escape insert) 9 | slurp/barf-cp 10 | ;; (mark insert) 11 | mark-toggle ; TODO: Check out readme. 12 | )) 13 | (lispyville--define-key '(motion normal visual) 14 | (kbd "^") #'lispy-left 15 | (kbd "M-h") #'lispyville-previous-opening 16 | (kbd "M-l") #'lispyville-next-opening 17 | (kbd "M-j") #'lispy-down 18 | (kbd "M-k") #'lispy-up 19 | (kbd "M-H") #'lispy-up-slurp ; lispy-down-slurp? 20 | (kbd "M-J") #'lispyville-drag-forward 21 | (kbd "M-K") #'lispyville-drag-backward 22 | (kbd "M-L") #'lispy-move-right ; lispy-up-slurp? 23 | (kbd "C-x C-e") #'lispy-eval 24 | (kbd "C-j") #'lispy-split 25 | (kbd "S-C-j") #'lispy-join 26 | (kbd "C-1") #'lispy-describe-inline 27 | (kbd "C-2") #'lispy-arglist-inline 28 | (kbd "C-4") #'lispy-x 29 | (kbd "gd") #'lispy-goto-symbol 30 | ;; (kbd "/") #'lispy-occur 31 | ;; (kbd "M-;") #'lispy-comment ; This conflicts with `iedit-toggle-selection' default binding. 32 | ;; TODO: lispy-eval-and-replace 33 | ")" #'lispy-right 34 | "=" #'lispyville-prettify) 35 | (lispyville--define-key 'insert 36 | (kbd "") 'lispy-delete-backward 37 | ";" 'lispy-comment 38 | ;; ":" 'lispy-colon ; The colon is not always used to delimit keys. 39 | "'" 'lispy-tick 40 | "`" 'lispy-backtick 41 | "\"" 'lispy-quotes 42 | "(" 'lispy-parens 43 | ")" 'lispy-right-nostring) 44 | (lispyville--define-key '(motion normal) 45 | ;; "q" 'lispy-ace-paren ; REVIEW: Conflicts with magit-blame's quit. Fixed? 46 | "Q" 'special-lispy-teleport ; TODO: Go to closest parenthesis if not on one. 47 | "q" 'lispy-ace-paren 48 | ;; "f" 'lispy-ace-paren 49 | ;; "Q" 'lispy-ace-symbol 50 | ;; "t" 'lispy-ace-char 51 | "Y" 'lispy-new-copy 52 | (kbd "S-") 'lispy-eval-other-window 53 | ;; "p" 'lispy-paste 54 | (kbd "M-C") 'lispy-clone ; TODO: Go to closest parenthesis if not on one. forward-char + lispyville-backward-up-list? 55 | "D" 'lispy-kill) 56 | 57 | (lispy-define-key lispy-mode-map-special "C" 'lispy-clone)) 58 | 59 | (defun ambrevar/init-lispy () 60 | (when (require 'lispy nil t) 61 | (set-face-foreground 'lispy-face-hint "#FF00FF") 62 | (when (require 'lispyville nil t) 63 | (add-hook 'lispy-mode-hook 'lispyville-mode)) 64 | (lispyville-mode))) 65 | 66 | (dolist (hook '(lisp-mode-hook 67 | common-lisp-mode-hook 68 | emacs-lisp-mode-hook 69 | scheme-mode-hook)) 70 | (add-hook hook 'ambrevar/turn-on-prettify-before-save) 71 | (add-hook hook 'ambrevar/turn-on-complete-filename) 72 | (add-hook hook 'ambrevar/turn-on-tab-width-to-8) ; Because some existing code uses tabs. 73 | (add-hook hook 'ambrevar/turn-off-indent-tabs) ; Should not use tabs. 74 | (add-hook hook 'ambrevar/init-lispy) 75 | (when (fboundp 'rainbow-delimiters-mode) 76 | (add-hook hook #'rainbow-delimiters-mode))) 77 | 78 | (when (require 'rainbow-delimiters nil t) 79 | ;; See https://yoo2080.wordpress.com/2013/09/08/living-with-rainbow-delimiters-mode/. 80 | ;; TODO: The color saturation metioned in the URL fails when running in daemon mode. 81 | ;; https://github.com/Fanael/rainbow-delimiters/issues/36 82 | (set-face-foreground 'rainbow-delimiters-depth-1-face "#fe1717") 83 | (set-face-foreground 'rainbow-delimiters-depth-2-face "#589cff") 84 | (set-face-foreground 'rainbow-delimiters-depth-3-face "#f1fe52") 85 | (set-face-foreground 'rainbow-delimiters-depth-4-face "#44ff4c") 86 | (set-face-foreground 'rainbow-delimiters-depth-5-face "#83b2ff") 87 | (set-face-foreground 'rainbow-delimiters-depth-6-face "#6161ff") 88 | (set-face-foreground 'rainbow-delimiters-depth-7-face "#35ff35") 89 | (set-face-foreground 'rainbow-delimiters-depth-8-face "#7ca8ff") 90 | (set-face-foreground 'rainbow-delimiters-depth-9-face "#50fec1") 91 | (set-face-attribute 'rainbow-delimiters-unmatched-face nil 92 | :foreground 'unspecified 93 | :inherit 'error 94 | :strike-through t)) 95 | 96 | ;;; Common LISP. 97 | (setq inferior-lisp-program "sbcl --noinform") 98 | ;; (add-hook 'slime-mode-hook 99 | ;; (lambda () 100 | ;; (unless (slime-connected-p) 101 | ;; (save-excursion (slime))))) 102 | 103 | ;;; Scheme. 104 | ;; (setq geiser-repl-skip-version-check-p t 105 | ;; geiser-mode-start-repl-p t) 106 | 107 | (provide 'init-lisp) 108 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-lua.el: -------------------------------------------------------------------------------- 1 | ;;; Lua 2 | 3 | (defvaralias 'lua-indent-level 'tab-width) 4 | 5 | (defun ambrevar/lua-set-compiler () 6 | (setq compile-command (concat lua-default-application " " (shell-quote-argument buffer-file-name)))) 7 | 8 | (add-hook 'lua-mode-hook 'ambrevar/lua-set-compiler) 9 | 10 | (provide 'init-lua) 11 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-makefile.el: -------------------------------------------------------------------------------- 1 | ;;; Makefile 2 | 3 | (ambrevar/define-keys makefile-mode-map 4 | "C-c c" 'ambrevar/makefile-config 5 | "C-c d" 'ambrevar/makefile-doc 6 | "C-c m" 'ambrevar/makefile-main 7 | "C-c s" 'ambrevar/makefile-c) 8 | 9 | (define-skeleton ambrevar/makefile-main 10 | "Insert root Makefile." nil 11 | "ROOT = . 12 | include ${ROOT}/config.mk 13 | 14 | ################################################################################ 15 | ## Build. 16 | 17 | .PHONY: all 18 | all: app doc 19 | 20 | .PHONY: app 21 | app: 22 | ${MAKE} -C ${srcdir} 23 | 24 | .PHONY: doc 25 | doc: 26 | ${MAKE} -C ${docsrcdir} 27 | 28 | .PHONY: debug 29 | debug: 30 | CFLAGS+=\"-g3 -O0 -DDEBUG=9\" ${MAKE} 31 | 32 | .PHONY: test 33 | test: 34 | ${MAKE} -C ${testdir} 35 | 36 | .PHONY: clean 37 | clean: 38 | ${MAKE} -C ${srcdir} clean 39 | ${MAKE} -C ${docsrcdir} clean 40 | ${MAKE} -C ${testdir} clean 41 | 42 | ################################################################################ 43 | ## Install / Uninstall. 44 | 45 | INSTALL ?= install 46 | INSTALL_DATA ?= ${INSTALL} -m644 47 | INSTALL_DIR ?= ${INSTALL} -d 48 | 49 | prefix ?= /usr/local 50 | exec_prefix ?= ${prefix} 51 | datarootdir ?= ${prefix}/share 52 | 53 | bindir ?= ${exec_prefix}/bin 54 | datadir ?= ${datarootdir} 55 | docdir ?= ${datarootdir}/doc 56 | includedir ?= ${prefix}/include 57 | infodir ?= ${datarootdir}/info 58 | libdir ?= ${exec_prefix}/lib 59 | libexecdir ?= ${exec_prefix}/libexecdir 60 | licensedir ?= ${datarootdir}/licenses 61 | localedir ?= ${datarootdir}/locale 62 | localstatedir ?= ${prefix}/var 63 | mandir ?= ${datarootdir}/man 64 | runstatedir ?= ${prefix}/run 65 | sbindir ?= ${exec_prefix}/sbin 66 | sharedstatedir ?= ${prefix}/com 67 | sysconfdir ?= ${perfix}/etc 68 | 69 | .PHONY: install 70 | install: 71 | ${MAKE} 72 | ${INSTALL_DIR} ${DESTDIR}${bindir} 73 | ${INSTALL} ${srcdir}/${cmdname} ${DESTDIR}${bindir}/${cmdname} 74 | ${INSTALL_DIR} ${DESTDIR}${mandir}/man1 75 | ${INSTALL_DATA} ${docsrcdir}/${cmdname}.1 ${DESTDIR}${mandir}/man1/${cmdname}.1 76 | ${INSTALL_DIR} ${DESTDIR}${licensedir}/${cmdname} 77 | ${INSTALL_DATA} LICENSE ${DESTDIR}${licensedir}/${cmdname}/LICENSE 78 | 79 | .PHONY: uninstall 80 | uninstall: 81 | -rm -f ${DESTDIR}${bindir}/${cmdname} 82 | -rmdir -p ${DESTDIR}${bindir} 83 | -rm -f ${DESTDIR}${mandir}/${cmdname}.${mansection}.gz 84 | -rmdir -p ${DESTDIR}${mandir} 85 | -rm -f ${DESTDIR}${licensedir}/${cmdname}/LICENSE 86 | -rmdir -p ${DESTDIR}${licensedir}/${cmdname} 87 | " > \n) 88 | 89 | (define-skeleton ambrevar/makefile-doc 90 | "Insert documentation Makefile." nil 91 | ".SUFFIXES: .in 92 | 93 | ROOT ?= .. 94 | include ${ROOT}/config.mk 95 | 96 | manpages = ${cmdname}.1 97 | 98 | all: ${manpages} 99 | 100 | .in: 101 | awk -v date=`date '+%Y-%m-%d'` 'BEGIN {section=\"$@\"; sub (/.*\\./, \"\", section); manname=toupper(\"$@\"); sub(/\\.[^.]+$$/, \"\", manname); print \".ds appname ${appname}\\n.ds authors ${authors}\\n.ds cmdname ${cmdname}\\n.ds date \" date \"\\n.ds manname \" manname \"\\n.ds section \" section \"\\n.ds version ${version}\\n.ds year ${year}\\n.\"}' > $@ 102 | cat $< >> $@ 103 | 104 | clean: 105 | rm -f ${manpages} 106 | " > \n) 107 | 108 | (define-skeleton ambrevar/makefile-c 109 | "Insert Makefile for building c." nil 110 | "ROOT ?= .. 111 | include ${ROOT}/config.mk 112 | 113 | CPPFLAGS += -DAUTHORS=\"${authors}\" -DVERSION=${version} -DYEAR=${year} 114 | CPPFLAGS += -D_POSIX_C_SOURCE=200809L 115 | CPPFLAGS += -DHAVE_INLINE 116 | LDLIBS += -lm 117 | 118 | ${cmdname}: ${cmdname}.o 119 | 120 | .PHONY: debug 121 | debug: 122 | CFLAGS+=\"-g3 -O0 -DDEBUG=9\" ${MAKE} 123 | 124 | .PHONY: clean 125 | clean: 126 | rm -f ${cmdname} *.d *.o 127 | 128 | ## Generate prerequisites automatically. GNU Make only. 129 | ## The 'awk' part is used to add the .d file itself to the target, so that it 130 | ## gets updated on changes. The -MQ option is to add full path to object files 131 | ## in subfolders. (-MM strips parent directories.) 132 | %.d: %.c 133 | ${CC} -MM -MQ ${<:.c=.o} ${CPPFLAGS} $< | awk -v stem=$* -v target=$@ '{gsub (stem \".o[ :]*\", stem \".o \" target \" : \")} 1' > $@ 134 | 135 | sources = $(wildcard *.c) 136 | deps = ${sources:.c=.d} 137 | -include ${deps} 138 | " > \n) 139 | 140 | (define-skeleton ambrevar/makefile-config 141 | "Insert Makefile config." nil 142 | "## This file is included by all (sub-)makefiles. 143 | 144 | ## Properties. 145 | appname = Name 146 | authors = Pierre Neidhardt 147 | cmdname = name 148 | url = 149 | version = 1.0 150 | year = " (format-time-string "%Y") " 151 | 152 | ## Folders. 153 | srcdir = src 154 | docsrcdir = doc 155 | testdir = tests 156 | 157 | ## USER SETTINGS 158 | 159 | ## Optional compilation flags. 160 | CFLAGS ?= -pedantic -std=c99 -Wall -Wextra -Wshadow 161 | 162 | ## END OF USER SETTINGS 163 | " > \n) 164 | 165 | (provide 'init-makefile) 166 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-markdown.el: -------------------------------------------------------------------------------- 1 | ;;; Markdown 2 | 3 | (set-face-attribute 'markdown-header-face-1 nil :inherit 'info-title-1) 4 | (set-face-attribute 'markdown-header-face-2 nil :inherit 'info-title-2) 5 | (set-face-attribute 'markdown-header-face-3 nil :inherit 'info-title-3) 6 | (set-face-attribute 'markdown-header-face-4 nil :inherit 'info-title-4) 7 | 8 | (define-key markdown-mode-map "\M-'" 'markdown-blockquote-region) 9 | 10 | (add-hook 'markdown-mode-hook 'ambrevar/turn-on-newline-paragraph) 11 | 12 | (provide 'init-markdown) 13 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-mediawiki.el: -------------------------------------------------------------------------------- 1 | ;;; MediaWiki 2 | 3 | ;;; This mode has numerous issue with network queries: 4 | ;;; https://github.com/hexmode/mediawiki-el/issues/ 5 | ;;; Besides you can try extending `url-cookie-save-interval'. 6 | ;;; Nonetheless is mode is helpfull for syntax awareness. 7 | 8 | (ambrevar/define-keys mediawiki-mode-map 9 | "C-c o" 'mediawiki-browse 10 | "M-g" nil ; This shadows M-g M-g. 11 | "C-x C-s" 'save-buffer 12 | "C-c M-s" 'mediawiki-save) 13 | 14 | (setq 15 | mediawiki-site-alist 16 | '(("Wikipedia" "http://en.wikipedia.org/w/" "Ambrevar" "" "Main Page") 17 | ("Wikibooks" "http://en.wikibooks.org/w/" "Ambrevar" "" "LaTeX") 18 | ("ArchLinux" "https://wiki.archlinux.org/" "Ambrevar" "" "Main Page") 19 | ("WikEmacs" "https://wikemacs.org/wiki/" "Ambrevar" "" "Main Page"))) 20 | 21 | (add-hook 'mediawiki-mode-hook 'visual-line-mode) 22 | (add-hook 'mediawiki-mode-hook 'turn-off-auto-fill) 23 | 24 | (define-skeleton ambrevar/mediawiki-tt 25 | "Insert truetype text." 26 | nil "" @ _ "" @) 27 | 28 | (provide 'init-mediawiki) 29 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-nroff.el: -------------------------------------------------------------------------------- 1 | ;;; Nroff 2 | 3 | (ambrevar/define-keys nroff-mode-map 4 | "C-c C-b" 'ambrevar/nroff-bold 5 | "C-c C-i" 'ambrevar/nroff-italic) 6 | 7 | ;;; Skeletons 8 | (define-skeleton ambrevar/nroff-bold "Bold text." nil "\\fB" @ _ "\\fR" @) 9 | (define-skeleton ambrevar/nroff-italic "Italic text." nil "\\fI" @ _ "\\fR" @) 10 | 11 | (provide 'init-nroff) 12 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-org.el: -------------------------------------------------------------------------------- 1 | ;;; Org mode 2 | 3 | ;;; TODO: org-import should be able to parse "|" in CSV files. 4 | 5 | (define-key org-mode-map (kbd "C-c C-a") 'org-agenda) 6 | 7 | (setq 8 | ;; Disable line splitting on M-RET. 9 | org-M-RET-may-split-line '((default)) 10 | org-insert-heading-respect-content t 11 | org-enforce-todo-dependencies t 12 | org-deadline-warning-days 7 13 | org-agenda-default-appointment-duration 60 14 | org-agenda-columns-add-appointments-to-effort-sum t 15 | org-ellipsis " […]" 16 | org-adapt-indentation nil 17 | ;; Add keywords. 18 | org-todo-keywords '((sequence "TODO" "REVIEW" "DONE")) 19 | ;; org-todo-keyword-faces '(("REVIEW" :inherit org-done)) 20 | ;; Priorities. 21 | org-priority-start-cycle-with-default nil 22 | org-default-priority 67 23 | ;; Org-mode aligns text. 24 | indent-tabs-mode nil) 25 | 26 | ;;; Agendas. 27 | (add-to-list 'org-agenda-files "~/personal/todo/todo.org") 28 | (defun ambrevar/org-switch-agenda-file (&optional other-window) 29 | "Switch between org-agenda and the first org-agenda-files." 30 | (interactive "P") 31 | (if (and buffer-file-name 32 | (member (expand-file-name buffer-file-name) (mapcar 'expand-file-name org-agenda-files))) 33 | (org-agenda) 34 | (let ((b (find-buffer-visiting (car org-agenda-files)))) 35 | (if b 36 | (if (get-buffer-window b) 37 | (select-window (get-buffer-window b)) 38 | (funcall (if other-window 'switch-to-buffer-other-window 'switch-to-buffer) b)) 39 | (funcall (if other-window 'find-file-other-window 'find-file) (car org-agenda-files)))))) 40 | 41 | (defun ambrevar/org-switch-agenda-file-other-window () 42 | "Like `ambrevar/org-switch-agenda-file' but use other window if possible." 43 | (interactive) 44 | (ambrevar/org-switch-agenda-file t)) 45 | 46 | ;;; Set PDF association in Org-mode (original is 'default). 47 | (setcdr (assoc "\\.pdf\\'" org-file-apps) 'emacs) 48 | 49 | ;;; Hooks. 50 | (dolist (fun '(ambrevar/turn-off-linum ambrevar/turn-off-indent-tabs turn-off-auto-fill)) 51 | (add-hook 'org-mode-hook fun)) 52 | 53 | (when (require 'org-contacts nil t) 54 | (let ((contacts "~/personal/contacts/contacts.org")) 55 | (when (file-exists-p contacts) 56 | ;; When used to auto-complete e-mail addresses, the file is automatically 57 | ;; loaded. The buffer usually need not be restored by a desktop session. 58 | (when desktop-save-mode 59 | (setq desktop-files-not-to-save 60 | (concat (substring desktop-files-not-to-save 0 -2) "\\|" (regexp-quote (expand-file-name contacts)) "\\)"))) 61 | (setq org-contacts-files (list contacts))))) 62 | 63 | (when (require 'org-bullets nil t) 64 | (add-hook 'org-mode-hook 'org-bullets-mode)) 65 | 66 | (provide 'init-org) 67 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-python.el: -------------------------------------------------------------------------------- 1 | ;;; Python 2 | 3 | (defun ambrevar/python-set-compiler () 4 | "Returns the value of the shebang if any, `python-shell-interpreter' otherwise." 5 | (when buffer-file-name 6 | (let* ((firstline 7 | (save-excursion (goto-char (point-min)) (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) 8 | (interpreter 9 | (if (not (string-match "^#!" firstline)) 10 | python-shell-interpreter 11 | (substring firstline 2)))) 12 | (setq compile-command 13 | (concat interpreter " " (shell-quote-argument buffer-file-name)))))) 14 | 15 | (add-hook 'python-mode-hook 'ambrevar/python-set-compiler) 16 | 17 | ;;; Doc lookup. Requires the python.info file to be installed. See 18 | ;;; https://bitbucket.org/jonwaltman/pydoc-info/. 19 | ;; (add-to-list 'load-path "~/path/to/pydoc-info") 20 | ;; (require 'pydoc-info nil t) 21 | 22 | (provide 'init-python) 23 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-sh.el: -------------------------------------------------------------------------------- 1 | ;;; Sh 2 | 3 | (defvaralias 'sh-basic-offset 'tab-width) 4 | (defvaralias 'sh-indentation 'sh-basic-offset) 5 | 6 | (setq sh-indent-comment t) 7 | 8 | (setq-default sh-shell-file "/bin/sh") 9 | ;; (setq-default sh-shell 'sh) 10 | 11 | ;;; Faces 12 | (set-face-foreground 'sh-heredoc "#00bfff") 13 | (set-face-bold 'sh-heredoc nil) 14 | 15 | (defun ambrevar/sh-set-compiler () 16 | "Set shell interpreter. 17 | Set `sh-shell', `sh-shell-file' and `compile-command' according to the following rules: 18 | - Look at shabang. 19 | - If file has no name, use default value of sh-shell-file. 20 | - Check extension or file name. 21 | - If none of the above yields a result, use default value of 22 | sh-shell-file. 23 | The advantages of this function over the vanilla code are: 24 | - You can change default value of sh-shell-file in sh-mode-hook 25 | and it will be used subsequently. 26 | - Zsh is supported 27 | - compile-command is set. 28 | - Once sh-shell is set, sh-shell-file is changed accordingly. In 29 | default Emacs, sh-shell-file is always the same." 30 | (interactive) 31 | (sh-set-shell 32 | (cond ((save-excursion 33 | (goto-char (point-min)) 34 | (looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)")) 35 | (match-string 2)) 36 | ((not buffer-file-name) sh-shell-file) 37 | ;; Checks that use `buffer-file-name' follow. 38 | ((string-match "\\.m?spec\\'" buffer-file-name) "rpm") 39 | ((string-match "[.]bash\\>" buffer-file-name) "bash") 40 | ((string-match "[.]csh\\>" buffer-file-name) "csh") 41 | ((string-match "[.]ksh\\>" buffer-file-name) "ksh") 42 | ((string-match "[.]sh\\>" buffer-file-name) "sh") 43 | ((string-match "[.]zsh\\>" buffer-file-name) "zsh") 44 | ((equal (file-name-nondirectory buffer-file-name) ".profile") "sh") 45 | (t sh-shell-file)) 46 | nil nil) 47 | ;; Universal version: 48 | ;; (setq sh-shell-file (executable-find (symbol-name sh-shell))) 49 | ;; Convenient version: 50 | (setq sh-shell-file (concat "/bin/" (symbol-name sh-shell))) 51 | ;; Sometimes with `git merge` it seems that the `buffer-file-name' is not a 52 | ;; string. We safe-guard that case. 53 | (when (stringp buffer-file-name) 54 | (setq compile-command (concat sh-shell-file " " (shell-quote-argument buffer-file-name))))) 55 | 56 | (defun ambrevar/sh-set-indent-rules () 57 | (setq sh-indent-for-case-label 0 58 | sh-indent-for-case-alt '+)) 59 | 60 | (defun ambrevar/sh-set-prompt () 61 | (set (make-local-variable 'defun-prompt-regexp) 62 | (concat "^\\(function[ \t]\\|[[:alnum:]_]+[ \t]+()[ \t]+\\)"))) 63 | 64 | ;;; Hooks 65 | (dolist (fun '(ambrevar/sh-set-indent-rules ambrevar/sh-set-prompt ambrevar/sh-set-compiler)) 66 | (add-hook 'sh-mode-hook fun)) 67 | 68 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 69 | 70 | (define-skeleton ambrevar/sh-commands-or-die 71 | "Insert a loop that exits if any of the commands is not found in path." 72 | "Command names: " 73 | > "for i " @ str "; do" \n 74 | > "if ! command -v \"$i\" >/dev/null 2>&1; then" \n 75 | > "echo >&2 \"'$i' not found\"" \n 76 | > "exit 1" \n 77 | "fi" > \n 78 | "done" > \n \n) 79 | 80 | (define-skeleton ambrevar/sh-ifcommand 81 | "Insert a test to check if command is found in path." 82 | "Command name: " 83 | > "if command -v " @ str " >/dev/null 2>&1; then" \n 84 | > @ _ \n 85 | "fi" > \n) 86 | 87 | (define-skeleton ambrevar/sh-while-getopts 88 | "Insert a getops prototype." 89 | "optstring: " 90 | > "usage() {" \n 91 | > "cat< \n 100 | \n 101 | > "while getopts :" str " OPT; do" \n 102 | > "case $OPT in" \n 103 | '(setq v1 (append (vconcat str) nil)) 104 | ((prog1 (if v1 (char-to-string (car v1))) 105 | (if (eq (nth 1 v1) ?:) 106 | (setq v1 (nthcdr 2 v1) 107 | v2 "\"$OPTARG\"") 108 | (setq v1 (cdr v1) 109 | v2 nil))) 110 | > str ")" \n 111 | > _ v2 " ;;" \n) 112 | > "\\?)" \n 113 | > "usage \"$0\"" \n 114 | "exit 1 ;;" > \n 115 | "esac" > \n 116 | "done" > \n 117 | \n 118 | "shift $(($OPTIND - 1))" \n 119 | "if [ $# -eq 0 ]; then" \n 120 | > "usage \"$0\"" \n 121 | "exit 1" \n 122 | "fi" > \n) 123 | 124 | (define-skeleton ambrevar/sh-while-read 125 | "Insert a while read loop." 126 | nil 127 | > "while IFS= read -r i; do" \n 128 | > @ _ \n 129 | "done < \n 130 | "EOF" > \n) 131 | 132 | (provide 'init-sh) 133 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-term.el: -------------------------------------------------------------------------------- 1 | ;;; Term 2 | 3 | ;;; TODO: Report `term-char-mode' fix upstream. 4 | ;;; 5 | ;;; Originally, `term-char-mode' check if point is after `pmark' and if it is, 6 | ;;; it cuts the characters between pmark and point and sends them to the 7 | ;;; terminal. The idea is that when you write a commandline in char mode, then 8 | ;;; switch to line mode and keep on writing _without moving the point_, you can 9 | ;;; go back to char mode and keep the modifications. 10 | ;;; 11 | ;;; I'd say this is rather useless as the point of line mode is to _move 12 | ;;; around_, not to do the same thing you can do in char mode. 13 | ;;; 14 | ;;; The more sensical thing to do: replace char-mode's commandline with 15 | ;;; line-mode's commandline and move char-mode point to where line-mode point 16 | ;;; is. 17 | (defun term-char-mode () 18 | "Switch to char (\"raw\") sub-mode of term mode. 19 | Each character you type is sent directly to the inferior without 20 | intervention from Emacs, except for the escape character (usually C-c)." 21 | (interactive) 22 | ;; FIXME: Emit message? Cf. elisp-raw-message 23 | (when (term-in-line-mode) 24 | (setq term-old-mode-map (current-local-map)) 25 | (use-local-map term-raw-map) 26 | (easy-menu-add term-terminal-menu) 27 | (easy-menu-add term-signals-menu) 28 | (let* (last-prompt 29 | commandline 30 | commandline-end-position 31 | (line-mode-point (point)) 32 | (proc (get-buffer-process (current-buffer))) 33 | (pmark (process-mark proc))) 34 | (save-excursion 35 | (goto-char (point-max)) 36 | (when (= (line-beginning-position) (line-end-position)) 37 | ;; Sometimes a spurious newline gets inserted. 38 | ;; Work around it by skipping back past it. 39 | (ignore-errors (backward-char))) 40 | (setq 41 | ;; If the prompt regexp is wrong or if we are on a multiline prompt, get the line-beginning-position. 42 | last-prompt (max (term-bol nil) (line-beginning-position)) 43 | ;; Yank last commandline. If prompt is not properly recognized, it yanks the whole line. 44 | commandline (buffer-substring-no-properties last-prompt (line-end-position)) 45 | ;; We store the end-position here so that we don't have to wait for the 46 | ;; process when we send the commandline. 47 | commandline-end-position (line-end-position))) 48 | 49 | (when (and (>= (point) last-prompt) 50 | ;; commandline can be empty (e.g. term is still initializing), 51 | ;; then no need to continue. 52 | (not (string-empty-p commandline))) 53 | ;; Clear line. 54 | (dotimes (_ (abs (- last-prompt pmark))) 55 | (term-send-backspace)) 56 | ;; Point could be before line-end-position, so we need to delete the trailing characters. 57 | (dotimes (_ (abs (- (point-max) pmark))) 58 | (term-send-del)) 59 | ;; Get prompt position with `process-mark'. 60 | ;; TODO: We need to wait a bit to make sure the previously-sent deletions have been processed. 61 | ;; This is brittle and it makes the prompt flicker once. 62 | ;; It is possible to work-around this: either use `term-prompt-regexp' 63 | ;; or send `term-left' enough times, wait and get it. That latter 64 | ;; solution has the advantage that it does not flickers, but it won't 65 | ;; work on dash. 66 | (sleep-for 0 100) 67 | (setq pmark (process-mark proc)) 68 | ;; Remove actual prompt length from the commandline. 69 | (setq commandline (substring commandline (- pmark last-prompt))) 70 | ;; Send commandline to term. 71 | (term-send-raw-string commandline) 72 | 73 | ;; Move char-mode point to line-mode point. TODO: Don't do this if shell does not support cursor moves. 74 | ;; Underlying shell can be retrieved with: 75 | ;; (car (last (process-command (get-buffer-process (current-buffer))))) 76 | (dotimes (_ (abs (- line-mode-point commandline-end-position))) 77 | (term-send-left))) 78 | 79 | ;; Finish up. 80 | (term-update-mode-line)))) 81 | 82 | (provide 'init-term) 83 | -------------------------------------------------------------------------------- /.emacs.d/lisp/init-tex.el: -------------------------------------------------------------------------------- 1 | ;;; TeX 2 | 3 | (dolist (fun '(ambrevar/turn-on-indent-tabs 4 | ;; ambrevar/turn-on-newline-paragraph 5 | prettify-symbols-mode)) 6 | (add-hook 'tex-mode-hook fun)) 7 | 8 | (defun ambrevar/tex-toggle-escape-char () 9 | "Make backslash part of the word syntax or not. 10 | This does not interfere with `subword-mode'." 11 | (interactive) 12 | (if (equal (char-syntax ?\\) ?\\) 13 | (progn 14 | (modify-syntax-entry ?\\ "w") 15 | (message "\\ is a not an escape character")) 16 | (modify-syntax-entry ?\\ "\\") 17 | (message "\\ is a an escape character"))) 18 | 19 | (with-eval-after-load 'tex ; AUCTeX 20 | (setq TeX-auto-save t 21 | TeX-parse-self t 22 | ;; Use pdf-tools to open PDF files 23 | TeX-view-program-selection '((output-pdf "PDF Tools")) 24 | TeX-source-correlate-start-server t 25 | ;; TeX-fold-auto t 26 | TeX-electric-escape t 27 | ;; TeX-electric-math t 28 | TeX-electric-sub-and-superscript t) 29 | (setq-default TeX-master nil) 30 | 31 | (when (require 'helm-config nil t) 32 | (define-key TeX-mode-map (kbd "M-s f") 'helm-semantic-or-imenu)) 33 | 34 | ;; Update PDF buffers after successful LaTeX runs 35 | (add-hook 'TeX-after-compilation-finished-functions 36 | #'TeX-revert-document-buffer)) 37 | 38 | ;;; Not sure how useful that is: 39 | ;; (set (make-local-variable 'use-hard-newlines) t) 40 | 41 | (provide 'init-tex) 42 | -------------------------------------------------------------------------------- /.emacs.d/lisp/patch-eshell-26.el: -------------------------------------------------------------------------------- 1 | ;;; Fix bug#29157: 25.3; Eshell parsing fails sometimes [...] 2 | (with-eval-after-load 'em-hist 3 | (defun eshell-hist-initialize () 4 | "Initialize the history management code for one Eshell buffer." 5 | ;; PATCH: Disable the history references. 6 | ;; (add-hook 'eshell-expand-input-functions 7 | ;; 'eshell-expand-history-references nil t) 8 | 9 | (when (eshell-using-module 'eshell-cmpl) 10 | (add-hook 'pcomplete-try-first-hook 11 | 'eshell-complete-history-reference nil t)) 12 | 13 | (if (and (eshell-using-module 'eshell-rebind) 14 | (not eshell-non-interactive-p)) 15 | (let ((rebind-alist eshell-rebind-keys-alist)) 16 | (make-local-variable 'eshell-rebind-keys-alist) 17 | (setq eshell-rebind-keys-alist 18 | (append rebind-alist eshell-hist-rebind-keys-alist)) 19 | (set (make-local-variable 'search-invisible) t) 20 | (set (make-local-variable 'search-exit-option) t) 21 | (add-hook 'isearch-mode-hook 22 | (function 23 | (lambda () 24 | (if (>= (point) eshell-last-output-end) 25 | (setq overriding-terminal-local-map 26 | eshell-isearch-map)))) nil t) 27 | (add-hook 'isearch-mode-end-hook 28 | (function 29 | (lambda () 30 | (setq overriding-terminal-local-map nil))) nil t)) 31 | (define-key eshell-mode-map [up] 'eshell-previous-matching-input-from-input) 32 | (define-key eshell-mode-map [down] 'eshell-next-matching-input-from-input) 33 | (define-key eshell-mode-map [(control up)] 'eshell-previous-input) 34 | (define-key eshell-mode-map [(control down)] 'eshell-next-input) 35 | (define-key eshell-mode-map [(meta ?r)] 'eshell-previous-matching-input) 36 | (define-key eshell-mode-map [(meta ?s)] 'eshell-next-matching-input) 37 | (define-key eshell-command-map [(meta ?r)] 38 | 'eshell-previous-matching-input-from-input) 39 | (define-key eshell-command-map [(meta ?s)] 40 | 'eshell-next-matching-input-from-input) 41 | (if eshell-hist-match-partial 42 | (progn 43 | (define-key eshell-mode-map [(meta ?p)] 44 | 'eshell-previous-matching-input-from-input) 45 | (define-key eshell-mode-map [(meta ?n)] 46 | 'eshell-next-matching-input-from-input) 47 | (define-key eshell-command-map [(meta ?p)] 'eshell-previous-input) 48 | (define-key eshell-command-map [(meta ?n)] 'eshell-next-input)) 49 | (define-key eshell-mode-map [(meta ?p)] 'eshell-previous-input) 50 | (define-key eshell-mode-map [(meta ?n)] 'eshell-next-input) 51 | (define-key eshell-command-map [(meta ?p)] 52 | 'eshell-previous-matching-input-from-input) 53 | (define-key eshell-command-map [(meta ?n)] 54 | 'eshell-next-matching-input-from-input))) 55 | 56 | (make-local-variable 'eshell-history-size) 57 | (or eshell-history-size 58 | (let ((hsize (getenv "HISTSIZE"))) 59 | (setq eshell-history-size 60 | (if (and (stringp hsize) 61 | (integerp (setq hsize (string-to-number hsize))) 62 | (> hsize 0)) 63 | hsize 64 | 128)))) 65 | 66 | (make-local-variable 'eshell-history-file-name) 67 | (or eshell-history-file-name 68 | (setq eshell-history-file-name (getenv "HISTFILE"))) 69 | 70 | (make-local-variable 'eshell-history-index) 71 | (make-local-variable 'eshell-save-history-index) 72 | 73 | (if (minibuffer-window-active-p (selected-window)) 74 | (set (make-local-variable 'eshell-save-history-on-exit) nil) 75 | (set (make-local-variable 'eshell-history-ring) nil) 76 | (if eshell-history-file-name 77 | (eshell-read-history nil t)) 78 | 79 | (add-hook 'eshell-exit-hook 'eshell-write-history nil t)) 80 | 81 | (unless eshell-history-ring 82 | (setq eshell-history-ring (make-ring eshell-history-size))) 83 | 84 | (add-hook 'eshell-exit-hook 'eshell-write-history nil t) 85 | 86 | (add-hook 'kill-emacs-hook 'eshell-save-some-history) 87 | 88 | (make-local-variable 'eshell-input-filter-functions) 89 | (add-hook 'eshell-input-filter-functions 'eshell-add-to-history nil t) 90 | 91 | (define-key eshell-command-map [(control ?l)] 'eshell-list-history) 92 | (define-key eshell-command-map [(control ?x)] 'eshell-get-next-from-history))) 93 | 94 | ;;; Fix 29854, expected in Emacs 26.1? 95 | (setq 96 | ansi-color-apply-face-function 97 | (lambda (beg end face) 98 | (when face 99 | (put-text-property beg end 'face face)))) 100 | 101 | ;;; REVIEW: Ignore dups in the entire ring, not just the last entry. 102 | ;;; Reported upstream, see #30466. 103 | (defun eshell-add-input-to-history (input) 104 | "Add the string INPUT to the history ring. 105 | Input is entered into the input history ring, if the value of 106 | variable `eshell-input-filter' returns non-nil when called on the 107 | input." 108 | (when (funcall eshell-input-filter input) 109 | (when eshell-hist-ignoredups 110 | (ring-remove eshell-history-ring 111 | (ring-member eshell-history-ring input))) 112 | (eshell-put-history input)) 113 | (setq eshell-save-history-index eshell-history-index) 114 | (setq eshell-history-index nil)) 115 | 116 | (provide 'patch-eshell-26) 117 | -------------------------------------------------------------------------------- /.emacs.d/lisp/patch-page.el: -------------------------------------------------------------------------------- 1 | ;;; page-number-mode 2 | 3 | (defvar page-number--mode-line-position-without-page nil) 4 | 5 | (defvar page-number--position 6 | '( 7 | ((column-number-mode 8 | (14 (:eval (propertize 9 | (format " (%%l,%%c,%d/%d)" (page-number) (page-count)) 10 | 'local-map mode-line-column-line-number-mode-map 11 | 'mouse-face 'mode-line-highlight 12 | 'help-echo "Line number and Column number\n\ 13 | mouse-1: Display Line and Column Mode Menu"))) 14 | (10 (:eval (propertize 15 | (format " L%%l,%d/%d" (page-number) (page-count)) 16 | 'local-map mode-line-column-line-number-mode-map 17 | 'mouse-face 'mode-line-highlight 18 | 'help-echo "Line Number\n\ 19 | mouse-1: Display Line and Column Mode Menu"))))) 20 | ((column-number-mode 21 | (9 (:eval (propertize 22 | (format " C%%c,%d/%d" (page-number) (page-count)) 23 | 'local-map mode-line-column-line-number-mode-map 24 | 'mouse-face 'mode-line-highlight 25 | 'help-echo "Column number\n\ 26 | mouse-1: Display Line and Column Mode Menu"))))))) 27 | 28 | ;;; This is different from `what-page' that returns a descriptive string. 29 | (defun page-count () 30 | "Return page count." 31 | (save-restriction 32 | (widen) 33 | (save-excursion 34 | (1+ (how-many 35 | page-delimiter 1 (point-max)))))) 36 | 37 | (defun page-number () 38 | "Return page number." 39 | (save-restriction 40 | (widen) 41 | (save-excursion 42 | (let ((count 1) 43 | (opoint (point))) 44 | (goto-char (point-min)) 45 | (while (re-search-forward page-delimiter opoint t) 46 | (if (= (match-beginning 0) (match-end 0)) 47 | (forward-char 1)) 48 | (setq count (1+ count))) 49 | count)))) 50 | 51 | (define-minor-mode page-number-mode 52 | "Toggle page number display in the mode line (Page Number mode). 53 | With a prefix argument ARG, enable Page Number mode if ARG is 54 | positive, and disable it otherwise. 55 | 56 | If called from Lisp, enable the mode if ARG is omitted or nil. 57 | 58 | It will only display if there is more than one page. A page is 59 | delimited by ‘page-delimiter’. 60 | 61 | WARNING: this may slow down editing on big files." 62 | :global t :group 'mode-line 63 | (let ((l mode-line-position)) 64 | (while (not (eq (caar l) 'line-number-mode)) 65 | (setq l (cdr l))) 66 | (if (not page-number-mode) 67 | ;; Restore. 68 | (setcdr (car l) page-number--mode-line-position-without-page) 69 | ;; Set. 70 | (unless page-number--mode-line-position-without-page 71 | (setq page-number--mode-line-position-without-page (cdar l))) 72 | (setcdr (car l) page-number--position)))) 73 | 74 | 75 | 76 | ;;; REVIEW: Fix forward-page. Previously, when the point was at the end of the 77 | ;;; page, going forward would skip 1 page. Changed: 78 | ;; 79 | ;; (if (bolp) (forward-char 1)) 80 | ;; 81 | ;;; to 82 | ;; 83 | ;; (if (string= page-delimiter "") 84 | ;; 85 | ;;; I do not know why the (bolp) condition was used since it does not match the 86 | ;;; above comment. 87 | ;;; Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20663. 88 | (defun forward-page (&optional count) 89 | "Move forward to page boundary. 90 | With prefix or COUNT, repeat, or go back if negative. 91 | A page boundary is any line whose beginning matches the regexp 92 | `page-delimiter'." 93 | (interactive "p") 94 | (or count (setq count 1)) 95 | (while (and (> count 0) (not (eobp))) 96 | ;; In case the page-delimiter matches the null string, 97 | ;; don't find a match without moving. 98 | (if (string= page-delimiter "") (forward-char 1)) 99 | (if (re-search-forward page-delimiter nil t) 100 | nil 101 | (goto-char (point-max))) 102 | (setq count (1- count))) 103 | (while (and (< count 0) (not (bobp))) 104 | ;; In case the page-delimiter matches the null string, 105 | ;; don't find a match without moving. 106 | (and (save-excursion (re-search-backward page-delimiter nil t)) 107 | (= (match-end 0) (point)) 108 | (goto-char (match-beginning 0))) 109 | (forward-char -1) 110 | (if (re-search-backward page-delimiter nil t) 111 | ;; We found one--move to the end of it. 112 | (goto-char (match-end 0)) 113 | ;; We found nothing--go to beg of buffer. 114 | (goto-char (point-min))) 115 | (setq count (1+ count)))) 116 | 117 | (provide 'init-page) 118 | -------------------------------------------------------------------------------- /.emacs.d/lisp/patch-smie.el: -------------------------------------------------------------------------------- 1 | ;;; Hack around SMIE 2 | ;;; This was intended to fix some undesirable behaviour related to forced alignment in indentation with Lua. 3 | ;;; See https://github.com/immerrr/lua-mode/issues/31. 4 | ;;; 2017-10-27: Not sure this is still valid. 5 | (require 'smie) 6 | 7 | (defcustom smie-align nil "Whether to align function arguments.") 8 | 9 | (defun smie-indent-exps () 10 | "Indentation of sequences of simple expressions without intervening keywords or operators. 11 | E.g. 'a b c' or `g (balbla) f'. Can be a list of expressions or a 12 | function call. If it's a function call, the first element is 13 | special (it's the function). We distinguish function calls from 14 | mere lists of expressions based on whether the preceding token is 15 | listed in the `list-intro' entry of smie-indent-rules. 16 | 17 | Overload original `smie-indent-exps': make alignment customizable 18 | in `smie-align'." 19 | 20 | ;; TODO: to indent Lisp code, we should add a way to specify 21 | ;; particular indentation for particular args depending on the 22 | ;; function (which would require always skipping back until the 23 | ;; function). 24 | ;; TODO: to indent C code, such as "if (...) {...}" we might need 25 | ;; to add similar indentation hooks for particular positions, but 26 | ;; based on the preceding token rather than based on the first exp. 27 | (save-excursion 28 | (let ((positions nil) 29 | arg) 30 | (while (and (null (car (smie-backward-sexp))) 31 | (push (point) positions) 32 | (not (smie-indent--bolp)))) 33 | (save-excursion 34 | ;; Figure out if the atom we just skipped is an argument rather 35 | ;; than a function. 36 | (setq arg 37 | (or (null (car (smie-backward-sexp))) 38 | (funcall smie-rules-function :list-intro 39 | (funcall smie-backward-token-function))))) 40 | (cond 41 | ((null positions) 42 | ;; We're the first expression of the list. In that case, the 43 | ;; indentation should be (have been) determined by its context. 44 | nil) 45 | (arg 46 | ;; There's a previous element, and it's not special (it's not 47 | ;; the function), so let's just align with that one. 48 | (goto-char (car positions)) 49 | (current-column)) 50 | ((cdr positions) 51 | ;; We skipped some args plus the function and bumped into something. 52 | (if (not smie-align) 53 | ;; Indent once. 54 | (+ (smie-indent--offset 'args) (current-column)) 55 | ;; Align with the first arg. 56 | (goto-char (cadr positions)) 57 | (current-column))) 58 | (positions 59 | ;; We're the first arg. 60 | (goto-char (car positions)) 61 | (+ (smie-indent--offset 'args) 62 | ;; We used to use (smie-indent-virtual), but that 63 | ;; doesn't seem right since it might then indent args less than 64 | ;; the function itself. 65 | (current-column))))))) 66 | 67 | (provide 'patch-smie) 68 | -------------------------------------------------------------------------------- /.gitconfig: -------------------------------------------------------------------------------- 1 | # -*- mode:conf -*- 2 | [user] 3 | email = ambrevar@gmail.com 4 | name = Pierre Neidhardt 5 | 6 | [color] 7 | ui = true 8 | 9 | [alias] 10 | b = branch -vva 11 | c = commit 12 | ca = commit -a 13 | co = checkout 14 | d = diff --color-words 15 | dc = diff --color-words --cached 16 | l = log --stat 17 | lol = log --graph --decorate --pretty=format:'%C(yellow)%h %Cgreen%cd%C(bold red)%d%Creset %s' --abbrev-commit --date=short 18 | m = mergetool 19 | r = remote -v 20 | s = status -uno 21 | su = status -uno -u 22 | 23 | [tar "tar.xz"] 24 | command = xz -c 25 | 26 | [push] 27 | default = current 28 | 29 | ## Ediff merge tool. 30 | ## See: 31 | ## http://kerneltrap.org/mailarchive/git/2007/7/1/250424 32 | ## http://stackoverflow.com/questions/1817370/using-ediff-as-git-mergetool 33 | [mergetool.ediff] 34 | cmd = emacs --eval \" (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \\\"Merge buffer saved in: %s\\\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\"))\" 35 | 36 | [merge] 37 | tool = ediff 38 | 39 | [sendemail] 40 | smtpencryption = tls 41 | smtpserver = smtp.gmail.com 42 | smtpuser = ambrevar@gmail.com 43 | smtpserverport = 587 44 | # to = guix-patches@gnu.org 45 | suppresscc = author 46 | # sendemail.confirm = auto 47 | # aliasfiletype = mutt 48 | # aliasesfile = ~/.mutt.d/aliases 49 | 50 | [core] 51 | pager = cat 52 | 53 | [man] 54 | viewer = catman 55 | 56 | [man "catman"] 57 | cmd = man -P cat 58 | 59 | [credential] 60 | helper = netrc 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.tmp 3 | .*_hook 4 | .Xauthority 5 | .abook 6 | .authinfo* 7 | .bash* 8 | .cache 9 | .config/QtProject.conf 10 | .config/gtk-2.0/ 11 | .config/mps-youtube/cache_py_3.4.5 12 | .config/mps-youtube/input_history 13 | .config/mps-youtube/play_history 14 | .config/mps-youtube/playlist_v2 15 | .config/mps-youtube/transcode 16 | .config/pulse/ 17 | .config/qutebrowser/bookmarks/ 18 | .config/qutebrowser/qsettings/ 19 | .config/qutebrowser/quickmarks 20 | .config/transmission-daemon/dht.dat 21 | .config/transmission-daemon/resume/ 22 | .config/transmission-daemon/stats.json 23 | .config/transmission-daemon/torrents/ 24 | .dbus 25 | .fontconfig 26 | .gimp* 27 | .gnupg 28 | .go* 29 | .lesshst 30 | .local/share/Trash 31 | .local/share/applications/wine* 32 | .local/share/emacs 33 | .local/share/icons 34 | .local/share/mime/* 35 | .mbsyncrc 36 | .mpv/watch_later 37 | .mtab.fuseiso 38 | .mu 39 | .nv/ 40 | .password-store 41 | .pfl.info 42 | .pki 43 | .pulse-cookie 44 | .serverauth* 45 | .ssh 46 | .steam/ 47 | .steampath 48 | .steampid 49 | .texlive* 50 | .thumbnails/ 51 | .wine 52 | games* 53 | go 54 | music* 55 | personal 56 | projects 57 | temp 58 | -------------------------------------------------------------------------------- /.gnupg/gpg-agent.conf: -------------------------------------------------------------------------------- 1 | ## 1-day timeout 2 | default-cache-ttl 86400 3 | max-cache-ttl 86400 4 | ## SSH 5 | enable-ssh-support 6 | default-cache-ttl-ssh 86400 7 | max-cache-ttl-ssh 86400 8 | ## Emacs pinentry 9 | # pinentry-program /usr/bin/pinentry-emacs 10 | pinentry-program /home/ambrevar/.guix-profile/bin/pinentry-emacs 11 | allow-emacs-pinentry 12 | allow-loopback-pinentry -------------------------------------------------------------------------------- /.gnupg/gpg.conf: -------------------------------------------------------------------------------- 1 | # keyserver hkp://pgp.mit.edu 2 | keyserver-options auto-key-retrieve 3 | # with-fingerprint 4 | with-keygrip 5 | ## SHA1 is too weak. 6 | ## https://www.schneier.com/blog/archives/2005/02/cryptanalysis_o.html 7 | personal-digest-preferences SHA256 8 | cert-digest-algo SHA256 9 | default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed -------------------------------------------------------------------------------- /.guix-packages/unrar.scm: -------------------------------------------------------------------------------- 1 | (define-module (unrar) 2 | #:use-module (guix licenses) 3 | #:use-module (guix packages) 4 | #:use-module (guix build-system gnu) 5 | #:use-module (guix download)) 6 | 7 | (define-public unrar 8 | (package 9 | (name "unrar") 10 | (version "5.6.4") 11 | (source (origin 12 | (method url-fetch) 13 | (uri (string-append "http://www.rarlab.com/rar/unrarsrc-" 14 | version 15 | ".tar.gz")) 16 | (sha256 17 | (base32 18 | "1zj9pbk38qf7anfk52xq5j9j7p7i007fhjy00x007wkh30hd4dck")))) 19 | (build-system gnu-build-system) 20 | (arguments 21 | `(#:tests? #f 22 | #:make-flags (list (string-append "DESTDIR=" (assoc-ref %outputs "out"))) 23 | #:phases 24 | (modify-phases %standard-phases 25 | (delete 'configure)))) 26 | (home-page "http://www.rarlab.com/rar_add.htm") 27 | (synopsis "The RAR uncompression program") 28 | (description "The RAR uncompression program.") 29 | (license ((@@ (guix licenses) license) "RARlab Copyright" 30 | "http://www.rarlab.com" 31 | "")))) 32 | -------------------------------------------------------------------------------- /.local/bin/.tc-video-custom.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} MODE 6 | 7 | This script was generated with tc-video-custom. 8 | 9 | It transcodes the embedded list of files using FFmpeg. MODE will specify what 10 | kind of output you want. Edit this file to fit your needs and learn more about 11 | FFmpeg. 12 | 13 | Modes: 14 | 15 | -f: Full video. 16 | -s: Sample of 5 minute starting at 1 minute. 17 | -S N: Sample of N minutes starting at 1 minute. 18 | 19 | EOF 20 | } 21 | 22 | SAMPLE="" 23 | OPT_PROCESS=false 24 | while getopts ":hfsS:" opt; do 25 | case $opt in 26 | h) 27 | usage 28 | exit ;; 29 | f) 30 | OPT_PROCESS=true ;; 31 | s) 32 | SAMPLE="-ss 60 -t 300" 33 | OPT_PROCESS=true ;; 34 | S) 35 | SAMPLE="-ss 60 -t $((60*$OPTARG))" 36 | OPT_PROCESS=true ;; 37 | \?) 38 | usage 39 | exit 1 ;; 40 | esac 41 | done 42 | 43 | shift $(($OPTIND - 1)) 44 | 45 | if ! $OPT_PROCESS; then 46 | usage 47 | exit 48 | fi 49 | 50 | if ! command -v ffmpeg >/dev/null 2>&1; then 51 | echo >&2 "'ffmpeg' not found" 52 | exit 1 53 | fi 54 | 55 | transcode () { 56 | ## You can choose here to process all files at the same time. Useful if you 57 | ## need to remux streams or to concatenate. 58 | # ffmpeg -i ###FILELIST \ 59 | ffmpeg -nostdin $SAMPLE -i "$@" \ 60 | -c:v libx264 -preset slow -crf 20 \ 61 | -c:a libvorbis -b:a 192k -ac 2 \ 62 | -c:s copy \ 63 | -dn \ 64 | -map 0 \ 65 | "${1%.*}-$(date '+%F-%H%M%S').mkv" 66 | } 67 | 68 | set -- ###FILENAMES 69 | 70 | ## Choose to process all files one after another. 71 | for i ; do 72 | transcode "$i" 73 | done 74 | 75 | ## Or all files at the same time. You have to change the ffmpeg input in the 76 | ## function. 77 | # transcode 78 | 79 | ################################################################################ 80 | ## USE CASES 81 | ## 82 | ## Exchange stream 1 an 2 by first removing them, then reading them in the 83 | ## desired order. 84 | ## 85 | ## -map -0:1 -map -0:2 -map 0:2 -map 0:1 86 | ## 87 | ## Change audio stream 1 title and remove audio stream 2 title: 88 | ## 89 | ## -metadata:s:a:0 title="FR: OGG Stereo" -metadata:s:a:1 title="" 90 | ## 91 | ## Demux audio: 92 | ## -vn -sn -c:a copy -map 0:1 93 | ## 94 | ## Dump audio to an ogg file: 95 | ## -vn -c:a libvorbis -b:a 192k 96 | ## 97 | ## Add a delay to audio (assuming stream 0 is video and stream 1 is audio) 98 | ## -i "$1" -itsoffset 0.300 -i "$1" -map 0:0 -map 1:1 99 | ## 100 | ## Insert stream 3 from file2 between all non-audio streams and audio streams of 101 | ## file1: 102 | ## -i "file1" -i "file2" -map -0:a map 1:3 -map 0:a 103 | ## 104 | ## Concatenate files. See for more 105 | ## details. 106 | ## 107 | ## -f concat -i list.txt -c copy out.ext 108 | ## 109 | ## with `cat list.txt`: 110 | ## file 'file1' 111 | ## file 'file2' 112 | ## 113 | ## With different codecs: 114 | ## 115 | ## -filter_complex '[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]' -map '[v]' -map '[a]' 116 | ## 117 | ################################################################################ 118 | 119 | ################################################################################ 120 | ## SOUND 121 | ## 122 | ## You should consider mixing down audio to 2 channels with '-ac 123 | ## 2'. This greatly reduce file size and avoid any confusion for playback, which 124 | ## is often the case when converting DTS to any other format because DTS has 125 | ## embedded channel description which is not available in other formats. 126 | ################################################################################ 127 | 128 | ################################################################################ 129 | ## X264 OPTIONS 130 | ## 131 | ## x264 presets (-preset ). 132 | ## preset ~= speed and quality*size ~= 1/speed 133 | ## ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo 134 | ## Recommended values: faster -- slow 135 | ## slow is approx. two times slower than fast, and reduces the size by approx. 10%. 136 | ## 137 | ## x264 overall quality (-crf) is a logarithmic scale. 138 | ## 18 is near perfection. 139 | ## 22 is really good compression, while a bit more blurry than the original. 140 | ## 20 is a good compromise. 141 | ## 142 | ## x264 tuning (-tune ). 143 | ## Possible values: film, animation, grain, ... 144 | ## See x264 --fullhelp. 145 | ## No tuning by default. 146 | ## 147 | ## x264 options (-x264opts me=). 148 | ## Possible values: hex, umh... 149 | ## me=umh is default. 150 | ################################################################################ 151 | 152 | ################################################################################ 153 | ## FALLACIOUS INPUT 154 | ## 155 | ## In general, FFmpeg is not so good at copying fallacious streams. Reecoding 156 | ## video and audio streams helps a lot. 157 | ## 158 | ## "Can't write packet with unknown timestamp" 159 | ## Put '-fflags genpts' before the input command. 160 | ################################################################################ 161 | 162 | ################################################################################ 163 | ## MISC 164 | ## To check what fmmpeg supports: 165 | ## $ ffmpeg -codecs 166 | ## $ ffmpeg -formats 167 | ## 168 | ## Useful guides: 169 | ## x264: http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide 170 | ## ID3 details: http://en.wikipedia.org/wiki/ID3 171 | ################################################################################ 172 | -------------------------------------------------------------------------------- /.local/bin/asciify: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [FILES] 6 | 7 | Convert non-ASCII characters to their ASCII equivalent. If no files are 8 | provided, use stdin. 9 | 10 | Options: 11 | 12 | -i: If files are provided, convert them in-place. 13 | 14 | EOF 15 | exit 16 | fi 17 | 18 | unset OPT 19 | if [ "$1" = "-i" ]; then 20 | OPT=-i 21 | shift 22 | fi 23 | 24 | ## Note that we also use 'sed -i' to edit files instead of 'ex'. Otherwise the 25 | ## code looks ugly if we try to handle both stdin and files with only one 26 | ## call. Besides, ex does not support multiple file editing. 27 | sed $OPT \ 28 | -e 's/[áàâä]/a/g' \ 29 | -e 's/[éèêë]/e/g' \ 30 | -e 's/[íìîï]/i/g' \ 31 | -e 's/[óòôö]/o/g' \ 32 | -e 's/[úùûü]/u/g' \ 33 | -e 's/[ýỳŷÿ]/y/g' \ 34 | -e 's/[ÁÀÂÄ]/A/g' \ 35 | -e 's/[ÉÈÊË]/E/g' \ 36 | -e 's/[ÍÌÎÏ]/I/g' \ 37 | -e 's/[ÓÒÔÖ]/O/g' \ 38 | -e 's/[ÚÙÛÜ]/U/g' \ 39 | -e 's/[ÝỲŶŸ]/Y/g' \ 40 | -e 's/[ñ]/n/g' \ 41 | -e 's/[œ]/oe/g' \ 42 | -e 's/[Œ]/Oe/g' \ 43 | -e 's/[æ]/ae/g' \ 44 | -e 's/[Æ]/Ae/g' \ 45 | -e 's/[ç]/c/g' \ 46 | -e 's/[Ç]/C/g' \ 47 | -e 's/[ß]/ss/g' \ 48 | -e 's/[«»„“”‚‘’]/"/g' \ 49 | -e 's/[©]/(C)/g' \ 50 | -e 's/[®]/(R)/g' \ 51 | -e 's/[™]/(TM)/g' \ 52 | -e 's/[¥]/Y/g' \ 53 | -e 's/[Ð]/D/g' \ 54 | -e 's/[ŀ]/l/g' \ 55 | -e 's/[Ŀ]/L/g' \ 56 | -e 's/[€]/euro/g' \ 57 | -e 's/[¢]/cent/g' \ 58 | -e 's/[£]/pound/g' \ 59 | -e 's/[µ]/mu/g' \ 60 | -e 's/[²]/^2/g' \ 61 | -e 's/[³]/^3/g' \ 62 | -e 's/[¡]/!/g' \ 63 | -e 's/[¿]/?/g' \ 64 | -e 's/[–‑]/-/g' \ 65 | -e 's/[…]/.../g' \ 66 | -e 's/[≤]/<=/g' \ 67 | -e 's/[≥]/>=/g' \ 68 | -e 's/[±]/+\/-/g' \ 69 | -e 's/[≠]/!=/g' \ 70 | -e 's/[⋅]/./g' \ 71 | -e 's/[×]/x/g' \ 72 | -e 's/[÷]/\//g' \ 73 | -e 's/[↓]/|/g' \ 74 | -e 's/[↑]/^/g' \ 75 | -e 's/[←]/<=/g' \ 76 | -e 's/[→]/=>/g' \ 77 | "$@" 78 | -------------------------------------------------------------------------------- /.local/bin/bsdman: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "${0##*/}" = "obsdman" ]; then 4 | OS=OpenBSD 5 | DOMAIN="http://www.openbsd.org/cgi-bin" 6 | MANPATH="OpenBSD+Current" 7 | else 8 | OS=FreeBSD 9 | DOMAIN="http://www.freebsd.org/cgi" 10 | MANPATH="FreeBSD+10-current" 11 | fi 12 | 13 | usage () { 14 | cat <&2 15 | Usage: ${0##*/} [SECTION] PAGE 16 | 17 | Fetch $OS man page PAGE from the official website and display it. 18 | 19 | EOF 20 | } 21 | 22 | [ $# -eq 0 ] && usage && exit 1 23 | [ "$1" = "-h" ] && usage && exit 24 | [ "$1" = "--" ] && shift 25 | 26 | SECTION=0 27 | PAGE=$1 28 | if [ $# -eq 2 ]; then 29 | SECTION="$1" 30 | PAGE="$2" 31 | fi 32 | 33 | 34 | AGENT="curl -s -L" 35 | if ! command -v curl >/dev/null 2>&1; then 36 | AGENT="wget -q -O - " 37 | fi 38 | 39 | $AGENT "$DOMAIN/man.cgi?query=$PAGE&apropos=0&sektion=$SECTION&manpath=$MANPATH&arch=default&format=ascii" | if [ "$TERM" = dumb ]; then cat; else less; fi 40 | -------------------------------------------------------------------------------- /.local/bin/clonecd: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] ISOFILE 6 | 7 | Dump optical disc to ISOFILE (without extension). 8 | 9 | Options: 10 | 11 | -h: Show this help. 12 | -d DRIVE: Set optical drive to use (e.g. 'sr1'). 13 | 14 | EOF 15 | } 16 | 17 | DRIVE=/dev/sr0 18 | while getopts ":hd:" opt; do 19 | case $opt in 20 | h) 21 | usage 22 | exit ;; 23 | d) 24 | DRIVE=/dev/$OPTARG ;; 25 | \?) 26 | usage 27 | exit 1 ;; 28 | esac 29 | done 30 | 31 | shift $((OPTIND - 1)) 32 | 33 | if [ $# -eq 0 ]; then 34 | usage 35 | exit 1 36 | fi 37 | 38 | if ! command -v readcd >/dev/null 2>&1; then 39 | echo >&2 "'readcd' not found" 40 | exit 1 41 | fi 42 | 43 | ## Fast? 44 | readcd dev="$DRIVE" f="$1.iso" -v retries=5 timeout=30 -noerror 45 | 46 | ## Slow 47 | # readcd f="$1.iso" -v retries=32 timeout=30 -s speed=16 -noerror 48 | 49 | # dd if=$DRIVE of='$1.iso' bs=2048 count=$(isosize -d 2048 $DRIVE) conv=sync,notrunc 50 | -------------------------------------------------------------------------------- /.local/bin/cpuusage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} 6 | 7 | Return the CPU usage. Linux only. 8 | 9 | EOF 10 | exit 11 | fi 12 | 13 | if [ ! "$(uname)" = "Linux" ]; then 14 | echo >&2 "Linux only." 15 | exit 1 16 | fi 17 | 18 | 19 | ## CPU usage 20 | ## 21 | ## A typical CPU array is (on Linux Kernel 3.0) 22 | ## cpu 158150 0 52354 18562746 1472 0 10198 0 0 0 23 | ## 24 | ## The meanings of the columns are as follows, from left to right: 25 | ## 26 | ## user: normal processes executing in user mode 27 | ## nice: niced processes executing in user mode 28 | ## system: processes executing in kernel mode 29 | ## idle: twiddling thumbs 30 | ## iowait: waiting for I/O to complete 31 | ## irq: servicing interrupts 32 | ## softirq: servicing softirqs 33 | ## ... (see 'man 5 proc' for further details) 34 | ## 35 | ## Only the first 4 values are interesting here. 36 | 37 | cpuarray="$(grep '^cpu ' /proc/stat)" 38 | ## We start at field #3 since there are 2 spaces after 'cpu'. 39 | f1=$(echo "$cpuarray" | cut -f3 -d' ') 40 | f2=$(echo "$cpuarray" | cut -f4 -d' ') 41 | f3=$(echo "$cpuarray" | cut -f5 -d' ') 42 | f4=$(echo "$cpuarray" | cut -f6 -d' ') 43 | 44 | totalA=$((f1+f2+f3+f4)) 45 | idleA=$f4 46 | sleep 1 47 | 48 | cpuarray="$(grep '^cpu ' /proc/stat)" 49 | f1=$(echo "$cpuarray" | cut -f3 -d' ') 50 | f2=$(echo "$cpuarray" | cut -f4 -d' ') 51 | f3=$(echo "$cpuarray" | cut -f5 -d' ') 52 | f4=$(echo "$cpuarray" | cut -f6 -d' ') 53 | 54 | totalB=$((f1+f2+f3+f4)) 55 | idleB=$f4 56 | 57 | totaldiff=$((${totalB:-0}-${totalA:-0})) 58 | 59 | if [ $totaldiff -eq 0 ]; then 60 | echo 0 61 | else 62 | echo "$((100 - 100 * (idleB-idleA) / totaldiff))" 63 | fi 64 | -------------------------------------------------------------------------------- /.local/bin/crun: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -eq 0 ]; then 4 | cat <&2 5 | Usage: ${0##*/} FILE [CFLAGS] 6 | 7 | Simulate a C interpreter by compiling, executing and removing file in one run. 8 | EOF 9 | exit 10 | fi 11 | 12 | [ -z "$CC" ] && CC=gcc 13 | INPUT="$1" 14 | 15 | shift 16 | [ $# -eq 0 ] && set -- -Wall -Wextra -Wshadow -pthread -lm -g3 -O0 17 | 18 | FILE="$(mktemp)" 19 | echo "==> $CC \"$INPUT\" -o \"$FILE\" $*" 20 | 21 | $CC "$INPUT" -o "$FILE" "$@" 22 | 23 | echo "==> $FILE" 24 | "$FILE" 25 | rm "$FILE" 26 | -------------------------------------------------------------------------------- /.local/bin/cxev: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | compat="" 4 | if awk --version | grep -q GNU; then 5 | # This is for hex-to-decimal conversion. 6 | compat="--non-decimal" 7 | fi 8 | xev "$@" | awk $compat '/KeyPress|KeyRelease/ { 9 | if ($1 == "KeyPress") 10 | event="pressed"; 11 | else 12 | event="released"; 13 | 14 | getline; getline; 15 | state = substr($2,1,length($2)-2); 16 | keycode = $4; 17 | keysym = substr($7, 1, length($7)-2); 18 | 19 | printf "%-16s code=%-3s state=%s event=%-8s", keysym, keycode, state, event 20 | 21 | getline; 22 | gsub(/\(|\)/, "", $5) 23 | code=int(sprintf("%d", "0x" $5)) 24 | if (code > 32 && code != 127) { 25 | /* Ignore non-printable characters" */ 26 | gsub(/"/, "", $NF) 27 | printf " string=%s", $NF 28 | } 29 | print "" 30 | }' 31 | -------------------------------------------------------------------------------- /.local/bin/dataindex: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] FOLDERS 6 | 7 | Output index of folder hierarchies to stdout. This is used as a small "backup" 8 | purpose. In case of data loss, it is still possible to get the full file list 9 | thanks to the indexes. 10 | 11 | Options: 12 | 13 | -f: When outputting to a file, overwrite if it exists. 14 | -w: Output each index to individual files in current folder. It uses the folder 15 | name as basename. 16 | EOF 17 | } 18 | 19 | opt_noclobber=true 20 | opt_file=false 21 | while getopts ":fhw" opt; do 22 | case $opt in 23 | f) 24 | opt_noclobber=false ;; 25 | h) 26 | usage 27 | exit ;; 28 | w) 29 | opt_file=true ;; 30 | \?) 31 | usage 32 | exit 1 ;; 33 | esac 34 | done 35 | 36 | shift $((OPTIND - 1)) 37 | 38 | if [ $# -eq 0 ]; then 39 | usage 40 | exit 1 41 | fi 42 | 43 | ## 'realpath' is required in case argument is ending with '.' or '..'. 44 | if ! command -v realpath >/dev/null 2>&1; then 45 | echo >&2 "'realpath' not found" 46 | exit 1 47 | fi 48 | 49 | for i ; do 50 | [ ! -d "$i" ] && continue 51 | 52 | ## We strip "./" from find's listing since we don't need it. We could avoid 53 | ## printing it in the first place, but there are several shortcomings: 54 | ## - Find over '.*' and '*', is bad practice since if will fail on 55 | ## non-existing files or for files beginning with a dash. 56 | ## - The 'printf' command in find is for GNU find only. 57 | 58 | ## 'LC_ALL=C sort' is required to make sure to output is consistent across 59 | ## different systems. 60 | 61 | ## The two following lines do the same for the same time cost. The former is shorter. 62 | # find "$i" -type f | awk -v str="$i" '{l=length(str)+2; print substr($0, l)}' | LC_ALL=C sort > "$OUTPUT" 63 | (cd -- "$i" && find . -type f) | sed 's/^.\///' | LC_ALL=C sort | \ 64 | if $opt_file; then 65 | i="$(realpath -- "$i")" 66 | base="${i##*/}" 67 | output="$base.index" 68 | [ -e "$output" ] && $opt_noclobber && output="$base-$(date +%F-%T).index" 69 | echo "$output" 70 | cat > "$output" 71 | else 72 | cat 73 | fi 74 | done 75 | -------------------------------------------------------------------------------- /.local/bin/demlo-sync: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | path='lib="/media/COWON S9/Music"' 4 | if [ ! -d "/media/COWON S9/Music" ]; then 5 | path='lib="/run/media/'$(id -nu)'/COWON S9/Music"' 6 | fi 7 | demlo -p -exist skip -r '' -pre "$path" -s 59-path-sync -s 60-path "$@" 8 | -------------------------------------------------------------------------------- /.local/bin/echokeymap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | KEYMAP="$HOME/.xkb/symbols/usim" 4 | 5 | if [ "$1" = "-h" ]; then 6 | cat <&2 7 | Usage: ${0##*/} KEYMAP 8 | 9 | Display KEYMAP in terminal. (Default: $KEYMAP) 10 | 11 | EOF 12 | exit 13 | fi 14 | [ "$1" = "--" ] && shift 15 | 16 | ## Keymap view in terminal 17 | [ $# -ne 0 ] && KEYMAP=$1 18 | awk '/━|┃|│|─/ {line=substr($0,4); print line}' "$KEYMAP" 19 | -------------------------------------------------------------------------------- /.local/bin/echopath: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} PATH 6 | 7 | Display PATH one entry per line. If PATH is not provided, use \$PATH by default. 8 | 9 | EOF 10 | exit 11 | fi 12 | 13 | if [ $# -ne 0 ]; then 14 | ARG="$1" 15 | else 16 | ARG="$PATH" 17 | fi 18 | 19 | case "$ARG" in 20 | *:*) SEP=':';; 21 | *\;*) SEP=';';; 22 | */*) SEP='/';; 23 | *,*) SEP=',';; 24 | *\|*) SEP='|';; 25 | *) SEP=':';; 26 | esac 27 | 28 | echo "$ARG" | awk -v RS=$SEP '1' 29 | -------------------------------------------------------------------------------- /.local/bin/ediff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | emacs --eval "(ediff \"$1\" \"$2\")" 4 | -------------------------------------------------------------------------------- /.local/bin/einfo: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for i in emacs realpath ; do 4 | if ! command -v $i >/dev/null 2>&1; then 5 | echo >&2 "'$i' not found" 6 | exit 1 7 | fi 8 | done 9 | 10 | [ -f "$1" ] && node="$(realpath "$1")" || node="$1" 11 | emacs --eval '(progn (info "'"$node"'")(delete-other-windows))' 12 | -------------------------------------------------------------------------------- /.local/bin/elisp: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] SCRIPT [ARGS...] 6 | 7 | Run Emacs Lisp SCRIPT. 8 | 9 | Options: 10 | 11 | -b: Byte-compile before running. 12 | -c: Remove byte code once finished. 13 | EOF 14 | } 15 | 16 | OPT_BYTE=false 17 | OPT_CLEAN=false 18 | while getopts :bc OPT; do 19 | case $OPT in 20 | b) 21 | OPT_BYTE=true ;; 22 | c) 23 | OPT_CLEAN=true ;; 24 | \?) 25 | usage 26 | exit 1 ;; 27 | esac 28 | done 29 | 30 | shift $((OPTIND - 1)) 31 | if [ $# -eq 0 ]; then 32 | usage 33 | exit 1 34 | fi 35 | 36 | if ! command -v emacs >/dev/null 2>&1; then 37 | echo >&2 'emacs not found' 38 | exit 1 39 | fi 40 | 41 | script="$1" 42 | if $OPT_BYTE && [ "${0##*.}" = "el" ]; then 43 | script="${1%.*}.elc" 44 | emacs -Q --batch -f batch-byte-compile "$1" 2>/dev/null 45 | fi 46 | shift 47 | 48 | emacs -Q --script "$script" "$@" 2>&1 49 | status=$? 50 | $OPT_CLEAN && rm "$script" 51 | exit $status 52 | -------------------------------------------------------------------------------- /.local/bin/em: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] [FILES] 6 | 7 | Start emacsclient in terminal or in X window if possible. Server is started on 8 | demand. 9 | 10 | The calling script can have different names: 11 | 12 | - emc: the Emacs instance is opened in the current terminal. 13 | - emw: if graphical, tell the client to wait. 14 | 15 | All emacsclient(1) options are supported: 16 | 17 | $(emacsclient --help) 18 | 19 | EOF 20 | exit 21 | fi 22 | 23 | if [ "${0##*/}" = "emc" ]; then 24 | ## Force terminal mode 25 | param="-t" 26 | else 27 | ## If Emacs cannot start in graphical mode, -c will act just like -t. 28 | param="-c" 29 | if [ "${0##*/}" != "emw" ] && [ -n "$DISPLAY" ] && [ "$(emacs --batch -Q --eval='(message (if (fboundp '"'"'tool-bar-mode) "X" "TTY"))' 2>&1)" = X ]; then 30 | ## Don't wait if not called with "emw" and if Emacs can start in graphical mode. 31 | ## The Emacs batch test checks whether it was compiled with GUI suppport. 32 | param="$param -n" 33 | fi 34 | fi 35 | 36 | emacsclient $param -a "" "$@" 37 | -------------------------------------------------------------------------------- /.local/bin/email: -------------------------------------------------------------------------------- 1 | #!emacs --script 2 | 3 | (require 'message) 4 | (require 'smtpmail) 5 | 6 | (setq 7 | message-sent-message-via '(mail mail) 8 | message-send-mail-function 'smtpmail-send-it) 9 | 10 | (unless (file-exists-p "~/.emailrc") 11 | (error "Missing ~/.emailrc. Need the following: 12 | (setq 13 | smtpmail-smtp-server \"smtp.example.org\" 14 | user-mail-address \"john.doe@example.org\" 15 | user-full-name \"John Doe\")")) 16 | (load "~/.emailrc" nil) 17 | 18 | (unless (file-exists-p "~/.authinfo.gpg") 19 | (error (format "Missing ~/.authinfo.gpg. Need the following: 20 | machine %s login MYLOGIN port 25 password MYPASSWORD" smtpmail-smtp-server))) 21 | 22 | (when (< (length command-line-args-left) 2) 23 | (error (format "Usage: %s SUBJECT TO... 24 | 25 | The e-mail body is read from the standard input (stdin)." 26 | (file-name-nondirectory (nth 2 command-line-args))))) 27 | 28 | (with-temp-buffer 29 | (insert (format " 30 | From: %s <%s> 31 | To: %s 32 | Subject: %s 33 | --text follows this line-- 34 | 35 | " 36 | user-full-name user-mail-address 37 | (mapconcat 'identity (cdr command-line-args-left) ", ") 38 | (nth 0 command-line-args-left))) 39 | (insert (read-from-minibuffer "")) 40 | (message-send)) 41 | -------------------------------------------------------------------------------- /.local/bin/emc: -------------------------------------------------------------------------------- 1 | em -------------------------------------------------------------------------------- /.local/bin/emw: -------------------------------------------------------------------------------- 1 | em -------------------------------------------------------------------------------- /.local/bin/git-get: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DOMAIN=github.com 4 | USER=ambrevar 5 | 6 | usage () { 7 | cat <&2 8 | Usage: ${0##*/} [OPTIONS] REPOS 9 | 10 | Clone git repo(s) from $DOMAIN:$USER. 11 | 12 | Options: 13 | 14 | -d DOMAIN: Set domain. 15 | -u USER: Set repository owner. 16 | 17 | EOF 18 | } 19 | 20 | while getopts ":d:u:" opt; do 21 | case $opt in 22 | d) 23 | DOMAIN=$OPTARG ;; 24 | u) 25 | USER=$OPTARG ;; 26 | \?) 27 | usage 28 | exit 1 ;; 29 | esac 30 | done 31 | 32 | shift $((OPTIND - 1)) 33 | 34 | if [ $# -eq 0 ]; then 35 | usage 36 | exit 1 37 | fi 38 | 39 | if ! command -v git >/dev/null 2>&1; then 40 | echo >&2 "'git' not found" 41 | exit 1 42 | fi 43 | 44 | for i; do 45 | git clone "git@$DOMAIN:/$USER/$i" || git clone "https://$DOMAIN/$USER/$i" 46 | done 47 | -------------------------------------------------------------------------------- /.local/bin/gnac: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [FILES] 6 | 7 | Grep non-ascii characters. If no files are provided, use stdin. 8 | 9 | EOF 10 | exit 11 | fi 12 | 13 | perl -ne 'chomp; print $_, "\n" if /[[:^ascii:]]/' "$@" 14 | -------------------------------------------------------------------------------- /.local/bin/hdmi-switch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] 6 | 7 | This script will enable all HDMI videos, passing xrandr OPTIONS to each one of 8 | them. 9 | 10 | To do this automatically when the cable is plugged, add the following 11 | udev rule (Linux only): 12 | 13 | $ cat /etc/udev/rules.d/hdmi.rules 14 | SUBSYSTEM=="drm", ACTION=="change", RUN+="/bin/sh $0" 15 | EOF 16 | } 17 | 18 | XRANDR_OPTIONS="$@" 19 | [ -z "$XRANDR_OPTIONS" ] && XRANDR_OPTIONS="--auto --noprimary" 20 | 21 | XRANDR_BUF=$(xrandr) 22 | PRIMARY=$(echo "$XRANDR_BUF" | awk '$1 !~ "HDMI" && $2 == "connected" {print $1; exit}') 23 | HDMI_OUTPUTS=$(echo "$XRANDR_BUF" | awk '$1 ~ "HDMI" && $2 == "connected" {printf $1 " "}') 24 | set -- $HDMI_OUTPUTS 25 | 26 | if [ $# -eq 0 ]; then 27 | echo xrandr --output $PRIMARY --auto --primary 28 | xrandr --output $PRIMARY --auto --primary 29 | else 30 | for i; do 31 | echo xrandr --output $i $XRANDR_OPTIONS 32 | xrandr --output $i $XRANDR_OPTIONS 33 | done 34 | echo 35 | echo "## Run this to turn off primary screen:" 36 | echo "# xrandr --output $PRIMARY --off" 37 | fi 38 | -------------------------------------------------------------------------------- /.local/bin/homeclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -- "$HOME/.bash_history" \ 4 | "$HOME/.cache/chromium" \ 5 | "$HOME/.cache/emacs" \ 6 | "$HOME/.cache/locatedb" \ 7 | "$HOME/.cache/qutebrowser" \ 8 | "$HOME/.cache/thumbnails" \ 9 | "$HOME/.config/gtk-2.0" \ 10 | "$HOME/.config/gtk-3.0" \ 11 | "$HOME/.config/qutebrowser/bookmarks" \ 12 | "$HOME/.config/qutebrowser/quickmarks" \ 13 | "$HOME/.esd_auth" \ 14 | "$HOME/.fehbg" \ 15 | "$HOME/.geiser_history.*" \ 16 | "$HOME/.gtk-bookmarks" \ 17 | "$HOME/.guile_history" \ 18 | "$HOME/.lesshst" \ 19 | "$HOME/.local/share/fish" \ 20 | "$HOME/.local/share/qutebrowser" \ 21 | "$HOME/.local/share/webkit" \ 22 | "$HOME/.mpv/watch_later" \ 23 | "$HOME/.mtap.fuseiso" \ 24 | "$HOME/.mu" \ 25 | "$HOME/.pulse-cookie" \ 26 | "$HOME/.python_history" \ 27 | "$HOME/.thumbnails" \ 28 | "$HOME/.tramp_history" \ 29 | "$HOME/.units_history" \ 30 | "$HOME/.wget-hsts" \ 31 | "$HOME/.w3m" 32 | 33 | echo "==> Files to be removed (beside trash):" 34 | echo "$@" | sed 's/ /\n/g' 35 | echo 36 | echo "==> Critical data:" 37 | for i in ~/.cache/mail ~/.password-store ~/personal ~/.ssh/*.pub; do 38 | [ -e "$i" ] && echo ":: WARNING: Found '$i'." 39 | done 40 | if [ -n "$(gpg --list-secret-keys)" ]; then 41 | echo ":: WARNING: Found PGP secret keys." 42 | fi 43 | 44 | CHOICE="N" 45 | echo 46 | echo ":: WARNING: Please close all applications before proceeding." 47 | echo -n "==> Clean home? (y/N) " 48 | read -r CHOICE 49 | case "$CHOICE" in 50 | Y|y) ;; 51 | *) 52 | echo "Nothing done." 53 | exit ;; 54 | esac 55 | 56 | echo 57 | echo "==> Empty trash:" 58 | if ! command -v trash-empty >/dev/null 2>&1; then 59 | echo ":: 'trash-empty' not installed, you must clean other drives manually." 60 | rm -rvf "$HOME/.local/share/Trash" 61 | else 62 | trash-empty 63 | fi 64 | 65 | echo 66 | echo "==> Delete garbage in $HOME:" 67 | rm -rvf "$@" 68 | -------------------------------------------------------------------------------- /.local/bin/homeinit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Initialize and update user profile. 3 | 4 | if [ "$1" = "-h" ]; then 5 | cat <&2 6 | Usage: ${0##*/} 7 | 8 | Initialize home folder. 9 | 10 | Options: 11 | 12 | -u: Skip large updates (packages, etc.) 13 | 14 | EOF 15 | exit 16 | fi 17 | 18 | OPT_UPDATE=true 19 | if [ "$1" = "-u" ]; then 20 | OPT_UPDATE=false 21 | shift 22 | fi 23 | 24 | SOURCEDIR="$HOME/personal" 25 | [ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config" 26 | [ -z "$XDG_DATA_HOME" ] && XDG_DATA_HOME="$HOME/.local/share" 27 | 28 | ## ln no-clobber 29 | lnn() { 30 | if [ -d "$2" ]; then 31 | set -- "$1" "$2/$(basename "$1")" 32 | fi 33 | if [ ! -e "$2" ] || [ -h "$2" ]; then 34 | ln -svnf "$1" "$2" 35 | fi 36 | } 37 | 38 | echo "==> Initial packages" 39 | if command -v pacman >/dev/null 2>&1; then 40 | sudo pacman --noconfirm -S --needed gnupg git stow 41 | elif command -v guix >/dev/null 2>&1; then 42 | guix package --install gnupg git stow 43 | fi 44 | 45 | echo "==> GPG" 46 | if [ -d ~/.gnupg ]; then 47 | chmod go-rwx ~/.gnupg ~/.gnupg/* 48 | if [ -e "$SOURCEDIR" ]; then 49 | git -C "$SOURCEDIR" pull 50 | else 51 | git clone git@gitlab.com:Ambrevar/personal 52 | fi 53 | if [ -e ~/.password-store ]; then 54 | git -C ~/.password-store pull 55 | else 56 | git clone git@gitlab.com:Ambrevar/password-store ~/.password-store 57 | fi 58 | else 59 | echo "~/.gnupg not found." 60 | fi 61 | 62 | echo "==> Persistent folders" 63 | for i in .emacs.d .local/share projects temp; do 64 | mkdir -pv "$HOME/$i" 65 | done 66 | 67 | ## TODO: Remove .bash_profile? 68 | echo "==> dotfiles" 69 | if [ -e ~/dotfiles ]; then 70 | git -C ~/dotfiles remote set-url origin git@github.com:Ambrevar/dotfiles 71 | git -C ~/dotfiles pull 72 | else 73 | git clone git@github.com:Ambrevar/dotfiles 74 | fi 75 | pushd ~/dotfiles 76 | stow -v . 77 | popd 78 | 79 | echo "==> System packages" 80 | if command -v pacman >/dev/null 2>&1; then 81 | pacman_list="" 82 | if [ -f ~/.pkglists/arch-official ]; then 83 | pacman_list="$(cat ~/.pkglists/arch-official)" 84 | fi 85 | sudo pacman --noconfirm -S --needed base base-devel $pacman_list 86 | if ! command -v cower >/dev/null 2>&1; then 87 | mkdir -p /tmp/cower 88 | pushd /tmp/cower 89 | curl https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=cower > PKGBUILD 90 | makepkg --noconfirm -si 91 | popd 92 | fi 93 | if ! command -v pacaur >/dev/null 2>&1; then 94 | mkdir -p /tmp 95 | cower -d pacaur 96 | pushd /tmp/pacaur 97 | makepkg --noconfirm -si 98 | popd 99 | fi 100 | if $OPT_UPDATE && [ -f ~/.pkglists/arch-aur ]; then 101 | pacaur --noconfirm --noedit -y --needed "$(cat ~/.pkglists/arch-aur)" 102 | fi 103 | pacman_list=$(pacman -Qdtq) 104 | if [ -n "$pacman_list" ]; then 105 | sudo pacman --noconfirm -Rs "$pacman_list" 106 | fi 107 | elif command -v guix >/dev/null 2>&1; then 108 | ## TODO: The manifest will uninstall other unspecified packages. Is this 109 | ## really what we want? 110 | guix package --manifest=~/.pkglists/guix 111 | fi 112 | 113 | echo "==> Bookmarks" 114 | mkdir -pv "$XDG_CONFIG_HOME/qutebrowser/bookmarks" 115 | lnn "$SOURCEDIR/bookmarks/bookmarks" "$XDG_CONFIG_HOME/qutebrowser/bookmarks/urls" 116 | lnn "$SOURCEDIR/bookmarks/quickmarks" "$XDG_CONFIG_HOME/qutebrowser/" 117 | 118 | if ! command -v emacs >/dev/null 2>&1 || \ 119 | [ $(emacs --quick --batch --eval '(message "%s" emacs-major-version)' 2>&1) -lt 26 ]; then 120 | pushd "$HOME/projects" 121 | [ -e emacs ] || git clone https://git.savannah.gnu.org/git/emacs.git 122 | if command -v guix >/dev/null 2>&1; then 123 | guix package --install emacs-dev 124 | else 125 | mkdir -p ../emacs-build 126 | cd ../emacs-build 127 | ../emacs/configure \ 128 | --disable-gtk-deprecation-warnings \ 129 | --without-pop \ 130 | --without-kerberos \ 131 | --without-kerberos5 \ 132 | --with-x-toolkit=gtk3 \ 133 | --with-jpeg \ 134 | --with-tiff \ 135 | --with-gif \ 136 | --with-png \ 137 | --with-rsvg \ 138 | --with-xml2 \ 139 | --with-imagemagick \ 140 | --with-xft \ 141 | --with-libotf \ 142 | --without-gsettings \ 143 | --without-gconf \ 144 | --with-gnutls \ 145 | --with-modules \ 146 | --with-threads 147 | popd 148 | sudo make install 149 | fi 150 | fi 151 | 152 | if command -v emacs >/dev/null 2>&1; then 153 | mkdir -pv "$HOME/.cache/emacs/" 154 | if ! command -v guix >/dev/null 2>&1; then 155 | if $OPT_UPDATE; then 156 | echo "==> Emacs ELPA packages" 157 | yes | emacs --batch -l ~/.emacs.d/init.el --eval '(progn (package-refresh-contents) (package-install-selected-packages))' 158 | fi 159 | fi 160 | echo "==> Emacs extra packages" 161 | mkdir -pv ~/.local/share/emacs/site-lisp 162 | for i in ~/.local/share/emacs/site-lisp/*; do 163 | echo "$i" 164 | git -C "$i" pull 165 | done 166 | fi 167 | 168 | echo "==> Mail" 169 | lnn "$SOURCEDIR/mail/mbsyncrc" "$HOME/.mbsyncrc" 170 | lnn "$SOURCEDIR/mail/authinfo.gpg" "$HOME/.authinfo.gpg" 171 | mkdir -pv "$HOME/.cache/mail/" 172 | while IFS= read -r i; do 173 | ## We get a shell command, so we need to evaluate it to expand "~". 174 | eval "$i" 175 | done <&2 5 | Usage: ${0##*/} 6 | 7 | Sync home folder: 8 | 9 | Options: 10 | 11 | -p: Push upstream. 12 | 13 | EOF 14 | exit 15 | fi 16 | 17 | OPT_UPDATE=false 18 | if [ "$1" = "-p" ]; then 19 | OPT_UPDATE=true 20 | shift 21 | fi 22 | 23 | PERSONAL_FOLDER="$HOME/personal" 24 | [ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config" 25 | [ -z "$XDG_DATA_HOME" ] && XDG_DATA_HOME="$HOME/.local/share" 26 | 27 | RED='\033[0;31m\033[1m' 28 | GREEN='\033[0;32m\033[1m' 29 | YELLOW='\033[0;33m\033[1m' 30 | BOLD='\033[0m\033[1m' 31 | NORMAL='\033[0m' 32 | 33 | section() { 34 | echo -e "$GREEN==> $@$NORMAL" 35 | } 36 | message() { 37 | echo -e "$YELLOW:: $@$NORMAL" 38 | } 39 | 40 | section "Generate package lists" 41 | pkglister 42 | 43 | project_status() { 44 | local path=$1 45 | local title=$2 46 | local body=$3 47 | 48 | [ -z "$body" ] && return 49 | 50 | if $CHANGED; then 51 | section "$path" 52 | CHANGED=false 53 | fi 54 | message "$title" 55 | echo "$body" 56 | } 57 | 58 | for i in ~/dotfiles ~/.password-store ~/personal ~/projects/* ~/.local/share/emacs/site-lisp/* "$@"; do 59 | [ ! -d "$i/.git" ] && continue 60 | CHANGED=true 61 | upstream=$(git -C "$i" rev-parse --abbrev-ref --symbolic-full-name @{u} 2>&1) 62 | if [ $? -eq 0 ]; then 63 | unmerged=$(git -C "$i" log --oneline "$upstream"..) 64 | project_status "$i" "Unmerged commits" "$unmerged" 65 | else 66 | project_status "$i" "Unmerged commits" "$upstream" 67 | fi 68 | project_status "$i" "Unstaged files" "$(git -C "$i" diff --name-only)" 69 | project_status "$i" "Staged files" "$(git -C "$i" diff --name-only --cached)" 70 | if $OPT_UPDATE && [ -n "$unmerged" ]; then 71 | message "Pushing" 72 | git -C "$i" push 73 | fi 74 | done 75 | 76 | ## TODO: Generate music, etc. indexes? 77 | -------------------------------------------------------------------------------- /.local/bin/imagemount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## User options: 4 | FUSEROOT="$HOME/fuse" 5 | 6 | mount () { 7 | [ ! -f "$1" ] && return 8 | 9 | DEVICE="$(cdemu status | awk 'NR>2 && $2==0 {print $1; found=1; exit} END {if(! found)print NR-2}')" 10 | DEV_COUNT="$(cdemu device-mapping | awk 'END {print NR-3}')" 11 | 12 | if cdemu status | grep -q "$1"; then 13 | echo >&2 "Image alredy mounted" 14 | return 15 | fi 16 | 17 | if [ "$DEVICE" -gt "$DEV_COUNT" ]; then 18 | while [ "$DEVICE" -gt "$DEV_COUNT" ]; do 19 | if ! cdemu add-device; then 20 | echo >&2 "Error adding device" 21 | return 22 | fi 23 | DEV_COUNT="$(cdemu device-mapping | awk 'END {print NR-3}')" 24 | done 25 | 26 | ## WARNING: adding a new device takes some time. If we want to avoid errors, 27 | ## we need to sleep until it is ready. 28 | echo "Waiting until ready..." 29 | while [ -z "$(cdemu device-mapping | awk -v devnum="$DEV_COUNT" 'NR>2 && $1==devnum {print $2}')" ]; do 30 | sleep 1 31 | done 32 | 33 | fi 34 | 35 | cdemu load "$DEVICE" "$1" 36 | if [ $? -ne 0 ] && command -v fuseiso >/dev/null 2>&1; then 37 | echo "Falling back to fuseiso." 38 | 39 | # LIST="$(mount | awk -v root="$FUSEROOT" '$1 == "fuseiso" && $3 ~ root {print $3}')" 40 | LIST=$(mount | awk -v root="$FUSEROOT" '$1 == "fuseiso" && $3 ~ root {sub(/^fuseiso on /,"");sub(/ type fuse.fuseiso [^ ]*$/, ""); print $0}') 41 | ALREADY="$(lsof -c fuseiso -F n | grep "$1")" 42 | 43 | if [ -n "$ALREADY" ]; then 44 | echo "Image alredy mounted." 45 | return 46 | fi 47 | 48 | COUNT=0 49 | while echo "$LIST" | grep -q "$FUSEROOT/drive-$COUNT"; do 50 | COUNT=$((COUNT+1)) 51 | done 52 | 53 | mkdir -p "$FUSEROOT/drive-$COUNT" 54 | fuseiso -p "$1" "$FUSEROOT/drive-$COUNT" 55 | 56 | else 57 | NODE="$(cdemu device-mapping | awk -v devnum="$DEVICE" 'NR>2 && $1==devnum {print $2}')" 58 | ## TODO: This is terrible, but checking cdemu status does not work. Maybe 59 | ## a kernel limitation. 60 | echo "Mounting..." 61 | sleep 2 62 | udiskie-mount "$NODE" 63 | fi 64 | 65 | } 66 | 67 | 68 | umount () { 69 | [ ! -d "$1" ] && return 70 | 71 | NODE="$(df | awk -v mount="$1" '$0 ~ mount {node=$1; gsub(/[^%]+% /, ""); if ($0 ~ mount){print node; exit}}')" 72 | 73 | if [ -n "$NODE" ]; then 74 | udiskie-umount "$1" 75 | 76 | DEVICE=$(cdemu device-mapping | awk -v node="$NODE" '$2 == node {print $1; exit}') 77 | cdemu unload "$DEVICE" 78 | elif command -v fuseiso >/dev/null; then 79 | fusermount -u "$1" 80 | rmdir "$1" >/dev/null 2>&1 81 | fi 82 | } 83 | 84 | usage () { 85 | cat <&2 86 | Usage: ${0##*/} FILES 87 | ${0##*/} -u FOLDERS 88 | 89 | Mount image files using CDEmu or fall back to fuseriso if available. It will 90 | not mount an image if already mounted. 91 | 92 | Options: 93 | 94 | -h: Show this help. 95 | -u: Unmount folders. 96 | 97 | EOF 98 | } 99 | 100 | OPT_UNMOUNT=false 101 | while getopts ":hu" opt; do 102 | case $opt in 103 | h) 104 | usage 105 | exit 1 ;; 106 | u) 107 | OPT_UNMOUNT=true ;; 108 | \?) 109 | usage 110 | exit 1 ;; 111 | esac 112 | done 113 | 114 | shift $((OPTIND - 1)) 115 | 116 | if [ $# -eq 0 ]; then 117 | usage 118 | exit 1 119 | fi 120 | 121 | ## realpath is needed to check if image was already mounted or not. 122 | for i in udiskie cdemu realpath; do 123 | if ! command -v $i >/dev/null 2>&1; then 124 | echo >&2 "'$i' not found" 125 | exit 1 126 | fi 127 | done 128 | 129 | if ! cdemu status >/dev/null 2>&1; then 130 | echo >&2 "CDemu failed to start" 131 | return 132 | fi 133 | 134 | if $OPT_UNMOUNT; then 135 | for i ; do 136 | umount "$(realpath "$i")" 137 | done 138 | else 139 | for i ; do 140 | mount "$(realpath "$i")" 141 | done 142 | fi 143 | -------------------------------------------------------------------------------- /.local/bin/lsofstat: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} 6 | 7 | Print number of open files per process. 8 | 9 | EOF 10 | exit 11 | fi 12 | 13 | lsof | awk '{x[$1]++} END {for(i in x) print i, x[i]}' | sort 14 | -------------------------------------------------------------------------------- /.local/bin/ltx: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] [FILES] 6 | 7 | LaTeX quick compiler. It adds the preambule and the "\end{document}" 8 | automatically. 9 | 10 | If no FILES are specified, use stdin. 11 | 12 | Options: 13 | 14 | -p PACKAGES: Use the comma separated list of packages. 15 | 16 | EOF 17 | exit 18 | fi 19 | [ "$1" = "--" ] && shift 20 | 21 | ## One line is mandatory. 22 | PREAMBLE='\documentclass[10pt,a4paper]{article}\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}\usepackage{amsmath,amssymb,amsfonts}\usepackage{geometry}\usepackage{lmodern}\usepackage{marvosym}\usepackage{textcomp}\DeclareUnicodeCharacter{20AC}{\EUR{}}\DeclareUnicodeCharacter{2264}{\leqslant}\DeclareUnicodeCharacter{2265}{\geqslant}' 23 | 24 | if [ "$1" = "-p" ]; then 25 | PACKAGES="\usepackage{$2}" 26 | shift 2 27 | fi 28 | 29 | if [ $# -eq 0 ]; then 30 | buf="$(cat)" 31 | cat <&2 5 | Usage: ${0##*/} FOLDER 6 | 7 | Print lints in mediafiles: 8 | 9 | - CBR audio 10 | - Less of more than 2 channels 11 | - Non-HD files 12 | - HD files without resolution in their names 13 | - Misspellings in subtitles (oe, \`, ´) 14 | - Embedded covers 15 | - Leading zeros in tags 16 | 17 | EOF 18 | } 19 | 20 | [ $# -eq 0 ] && usage && exit 1 21 | [ "$1" = "-h" ] && usage && exit 22 | [ "$1" = "--" ] && shift 23 | 24 | if ! command -v mediainfo >/dev/null 2>&1; then 25 | echo >&2 "mediainfo required." 26 | exit 1 27 | fi 28 | 29 | subtitle () { 30 | buffer=$(cat "$1") 31 | echo "$buffer" | grep -q "\`" && echo "$i: Misspelling (\`)" 32 | echo "$buffer" | grep -q "´" && echo "$i: Misspelling (´)" 33 | echo "$buffer" | grep -q "oe" && echo "$i: Misspelling (oe)" 34 | } 35 | 36 | media () { 37 | buffer=$(mediainfo "$1") 38 | echo "$buffer" | grep -q "Bit rate mode *: Constant" && echo "$i: CBR audio" 39 | echo "$buffer" | grep -q "Cover *: Yes" && echo "$i : Embedded cover(s)" 40 | echo "$buffer" | grep -q "Track name/Position *: 0+" && echo "$i: Leading zeros in tags" 41 | echo "$buffer" | grep -q "Channel(s) *: 1 channel" && echo "$i: Only 1 audio channel" 42 | echo "$buffer" | grep -q "Channel(s) *: (2[0-9]+|[013-9]+) channels" && echo "$i: More than 2 audio channels" 43 | 44 | width=$(echo "$buffer" | awk '/^Width *:/ {gsub(/[^0-9]/, ""); print; exit} ') 45 | if [ -n "$width" ]; then 46 | if [ "$width" -lt 1200 ]; then 47 | echo "$i: Non-HD" 48 | else 49 | echo "$i" | grep -q "\[720\]|\[1080\]" || echo "$i: HD file without resolution in filename" 50 | fi 51 | fi 52 | } 53 | 54 | for i ; do 55 | l=$(echo "$i" | awk '{print tolower($0)}') 56 | case "$l" in 57 | *.srt|*.sub|*.ass) 58 | subtitle "$i" 59 | exit ;; 60 | esac 61 | 62 | media "$i" 63 | done 64 | -------------------------------------------------------------------------------- /.local/bin/mediastats: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FOLDERS 6 | 7 | Sort media files in FOLDERS by duration. 8 | 9 | EOF 10 | } 11 | 12 | [ $# -eq 0 ] && usage && exit 1 13 | [ "$1" = "-h" ] && usage && exit 14 | [ "$1" = "--" ] && shift 15 | 16 | for i; do 17 | find "$i" -type f -exec mediainfo {} + 18 | done | awk '/^General$/ {while($1!="Complete") getline; gsub(/^[^:]*: /,""); path=$0; while($0!="") {if($1=="Duration"){gsub(/^[^:]*: /,""); duration=$0; time=0; for(i=1;i<=NF;i+=2){if($(i+1)=="h") time+=$i*3600; if($(i+1)=="min") time+=$i*60; if($(i+1)=="s") time+=$i }; printf "%s %s '"'"'%s'"'"'\n", time, duration, path; break} else {getline}}}' | sort -n 19 | -------------------------------------------------------------------------------- /.local/bin/mover: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | ${0##*/} FOLDERS DEST 6 | 7 | Merge FOLDERS content into DEST. Existing files and folders will remain. It does 8 | not overwrite by default. Empty folders are ignored. The resulting hierarchy is: 9 | 10 | DEST/FOLDER1/ 11 | DEST/FOLDER2/ 12 | ... 13 | 14 | Options: 15 | -f: Overwrite destination. 16 | -r: Remove empty folders. 17 | 18 | WARNING: Do not use over filenames with newlines. 19 | 20 | EOF 21 | } 22 | 23 | OPT_OVERWRITE=false 24 | OPT_DELEMPTY=false 25 | 26 | while getopts ":fhr" opt; do 27 | case $opt in 28 | h) 29 | usage 30 | exit 1 ;; 31 | f) 32 | OPT_OVERWRITE=true ;; 33 | r) 34 | OPT_DELEMPTY=true ;; 35 | \?) 36 | usage 37 | exit 1 ;; 38 | esac 39 | done 40 | 41 | shift $((OPTIND - 1)) 42 | if [ $# -eq 0 ]; then 43 | usage 44 | exit 1 45 | fi 46 | 47 | ## The counter is used to process all arguments but the last one. We can get the 48 | ## last argument with an 'eval'. (Safe here.) 49 | DEST="$(eval "echo \$$#")" 50 | count=0 51 | 52 | for i ; do 53 | count=$((count+1)) 54 | [ $count -eq $# ] && break 55 | 56 | while IFS= read -r FILE; do 57 | DESTFILE="$DEST/$FILE" 58 | if [ ! -e "$DESTFILE" ] || $OPT_OVERWRITE; then 59 | mkdir -p "$(dirname "$DESTFILE")" 60 | mv -v "$i/../$FILE" "$DESTFILE" 61 | 62 | if $OPT_DELEMPTY; then 63 | PARENT="$FOLDER/../$FILE" 64 | PARENT="${PARENT%/*}" 65 | rmdir "$PARENT" 2>/dev/null 66 | fi 67 | fi 68 | 69 | ## We switch to $i so that 'find' strips the parent dirs from the path. 70 | done <&2 5 | Usage: ${0##*/} IP 6 | 7 | Print the map of the network associated to the provided IP. 8 | EOF 9 | } 10 | 11 | [ $# -ne 1 ] && usage && exit 1 12 | [ "$1" = "-h" ] && usage && exit 13 | [ "$1" = "--" ] && shift 14 | 15 | ## Network operations 16 | if ! command -v nmap >/dev/null 2>&1; then 17 | echo >&2 "'nmap' not found" 18 | exit 1 19 | fi 20 | 21 | echo "$1" 22 | for SCANIP in $( nmap -sL "$1" | grep -i "\([[:digit:]]\+\.\)\{3,\}[[:digit:]]\+" | awk '{print $5}' ); do 23 | sudo nmap -oX - -n -sT -T Normal -O -sR -I -F -P0 "$SCANIP" 24 | echo 25 | done 26 | -------------------------------------------------------------------------------- /.local/bin/netscan: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if ! command -v nmap >/dev/null 2>&1; then 4 | echo >&2 "'nmap' not found" 5 | exit 1 6 | fi 7 | 8 | SUBNET="$(ifconfig | awk '/inet / && $0 !~ "127.0.0.1" {gsub(/\.[0-9]+$/, ".*", $2) ; print $2}')" 9 | echo "Scanning '$SUBNET'..." 10 | nmap -sn "$SUBNET" 11 | -------------------------------------------------------------------------------- /.local/bin/netspeed: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [INTERFACE] 6 | 7 | Return up and down transmission speed on given interface. If not given, use the 8 | first online interface returned by ifconfig (lo is ignored). 9 | EOF 10 | } 11 | 12 | [ $# -gt 1 ] && usage && exit 1 13 | [ "$1" = "-h" ] && usage && exit 14 | 15 | if [ -n "$1" ]; then 16 | interface="$1" 17 | else 18 | interface="$(ifconfig | grep -vm1 '^lo\|^ \|^$' | cut -f1 -d':')" 19 | ## AWK alternative 20 | # ifconfig | awk -F: '!/^ / && !/^$/ && $1!="lo" {print $1;exit}' 21 | fi 22 | 23 | if [ ! -d "/sys/class/net/${interface}" ]; then 24 | echo >&2 "Error: no such interface: ${interface}" 25 | else 26 | path="/dev/shm/netspeed" 27 | time=$(date +%s) 28 | 29 | read -r rx < /sys/class/net/"$interface"/statistics/rx_bytes 30 | read -r tx < /sys/class/net/"$interface"/statistics/tx_bytes 31 | 32 | if [ ! -f "$path" ]; then 33 | echo "$time $rx $tx" > "$path" 34 | chmod 0666 "$path" 35 | fi 36 | 37 | read -r time_old rx_old tx_old < "$path" 38 | echo "$time $rx $tx" > "$path" 39 | time_diff=$((time - time_old)) 40 | 41 | if [ "$time_diff" -gt 0 ]; then 42 | rx_rate=$(((rx - rx_old) / time_diff)) 43 | tx_rate=$(((tx - tx_old) / time_diff)) 44 | 45 | [ "$rx_rate" -gt 1024 ] && rx_rate=$((rx_rate / 1024)) && rx_unit=K 46 | [ "$rx_rate" -gt 1024 ] && rx_rate=$((rx_rate / 1024)) && rx_unit=M 47 | 48 | [ "$tx_rate" -gt 1024 ] && tx_rate=$((tx_rate / 1024)) && tx_unit=K 49 | [ "$tx_rate" -gt 1024 ] && tx_rate=$((tx_rate / 1024)) && tx_unit=M 50 | 51 | printf "%s %s↓ %s %s↑" "$rx_rate" "$rx_unit" "$tx_rate" "$tx_unit" 52 | fi 53 | fi 54 | -------------------------------------------------------------------------------- /.local/bin/obsdman: -------------------------------------------------------------------------------- 1 | bsdman -------------------------------------------------------------------------------- /.local/bin/pacman/pacfiles: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [PACKAGES] 6 | 7 | List of files in pacman packages sorted by size 8 | 9 | EOF 10 | exit 11 | fi 12 | 13 | pacman -Qlq "$@" | grep -v '/$' | xargs du -cbh | sort -h 14 | -------------------------------------------------------------------------------- /.local/bin/pacman/pachist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [COUNT] 6 | 7 | List pacman's COUNT last installed packages 8 | 9 | EOF 10 | exit 11 | fi 12 | 13 | [ -z "$1" ] && set -- 30 14 | expac -t '%F %T' '%-8l %n' | sort -rn | head -$1 15 | -------------------------------------------------------------------------------- /.local/bin/pacman/pacman-diff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [-m] [-e] [-q] FILES... 6 | 7 | Display packages listed in FILES but not installed. 8 | 9 | -e: Compare FILE to explicitly installed packages. 10 | -h: Display this help. 11 | -m: Compare FILE to foreign installed packages. 12 | -q: Display installed packages not included in FILE. 13 | EOF 14 | } 15 | 16 | OPTION_EXPLICIT="" 17 | OPTION_FOREIGN="" 18 | OPTION_LOCAL="-1" 19 | 20 | while getopts ":hmqe" opt; do 21 | case $opt in 22 | e) 23 | OPTION_EXPLICIT="e" ;; 24 | h) 25 | usage 26 | exit 1 ;; 27 | m) 28 | OPTION_FOREIGN="m" ;; 29 | q) 30 | OPTION_LOCAL="-2" ;; 31 | \?) 32 | usage 33 | exit 1 ;; 34 | esac 35 | done 36 | 37 | shift $((OPTIND - 1)) 38 | 39 | if [ $# -eq 0 ]; then 40 | echo "Missing argument." 41 | usage 42 | exit 1 43 | fi 44 | 45 | if ! command -v pacman >/dev/null 2>&1; then 46 | echo >&2 "'pacman' not found" 47 | exit 1 48 | fi 49 | 50 | PKGLIST="$(mktemp)" 51 | FILE="$(mktemp)" 52 | pacman -Qq${OPTION_FOREIGN}${OPTION_EXPLICIT} | LC_ALL=C sort > "$PKGLIST" 53 | LC_ALL=C sort "$@" > "$FILE" 54 | LC_ALL=C comm -3 ${OPTION_LOCAL} "$PKGLIST" "$FILE" 55 | rm -f "$PKGLIST" "$FILE" 56 | -------------------------------------------------------------------------------- /.local/bin/pacman/pacsize: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # pacsize -- display package sizes 3 | # 4 | # Copyright (C) 2014 Pierre Neidhardt 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # as published by the Free Software Foundation; either version 2 9 | # of the License, or (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | 19 | readonly myname='pacsize' 20 | readonly myver='4.1.2' 21 | 22 | calc_total () { 23 | awk 'BEGIN { 24 | unit["B"] = 1/1024 25 | unit["KiB"] = 1 26 | unit["MiB"] = 1024 27 | unit["GiB"] = 1048576 28 | unit["TiB"] = 1073741824 29 | unit["PiB"] = 1099511627776 30 | unit["EiB"] = 1125899906842624 31 | unit["ZiB"] = 1152921504606846976 32 | unit["YiB"] = 1180591620717411303424 33 | } 34 | 35 | { 36 | u=$1 37 | gsub(/[[:digit:]]*/, "", u) 38 | n=$1 39 | gsub(/[[:alpha:]]*/, "", n) 40 | total += unit[u]*n 41 | print 42 | } 43 | END { 44 | printf ("%7s KIB TOTAL\n", total) 45 | }' 46 | } 47 | 48 | error () { 49 | echo >&2 "$@" 50 | } 51 | 52 | ## Print size and name. We round to the lowest integer, this makes output 53 | ## lighter. 54 | filter () { 55 | awk -F ": " \ 56 | '$0 ~ "^Name" { 57 | pkg = $2 58 | } 59 | $0 ~ "^Installed Size" { 60 | split($2, a, " ") 61 | printf ("%4d%-3s %s\n", a[1], a[2], pkg) 62 | }' 63 | } 64 | 65 | remove_duplicates () { 66 | awk '! table[$0]++' 67 | } 68 | 69 | usage () { 70 | cat <&2 71 | Usage: ${0##*/} [OPTIONS] PACKAGES 72 | ${0##*/} -a [OPTIONS] 73 | 74 | Display the size of PACKAGES. Duplicates are removed if any. The local database 75 | is queried first; if the package is not found, the sync database is then used 76 | for lookup. 77 | 78 | Options: 79 | 80 | -a: Process all installed packages. 81 | -h: Show this help. 82 | -n: Sort output by name. 83 | -s: Sort output by size. 84 | -t: Print total. 85 | -V: Show version information. 86 | 87 | Examples: 88 | 89 | $ ${0##*/} -ast 90 | Convenient way to keep track of big packages. 91 | 92 | $ ${0##*/} \$(pactree -ld1 linux) 93 | Print the size of linux and all its direct dependencies. 94 | 95 | $ ${0##*/} -st \$(pacman -Qdtq) 96 | Print a grand total of orphan packages, and sort by size. 97 | EOF 98 | } 99 | 100 | version () { 101 | echo "$myname $myver" 102 | echo 'Copyright (C) 2014 Pierre Neidhardt ' 103 | } 104 | 105 | opt_sort=false 106 | opt_all=false 107 | opt_total=false 108 | 109 | while getopts ":ahnstV" opt; do 110 | case $opt in 111 | a) 112 | opt_all=true ;; 113 | h) 114 | usage 115 | exit ;; 116 | n) 117 | opt_sort="sort -k3" ;; 118 | s) 119 | opt_sort="sort -h" ;; 120 | t) 121 | opt_total="calc_total" ;; 122 | V) 123 | version "$0" 124 | exit ;; 125 | \?) 126 | usage 127 | exit 1 ;; 128 | esac 129 | done 130 | 131 | shift $((OPTIND - 1)) 132 | 133 | ## All-packages mode. 134 | ## We use a dedicated algorithm which is much faster than per-package mode. 135 | ## Unfortunately there is no easy way to select packages with this method. 136 | if $opt_all; then 137 | DBPath="$(awk -F "=[ \t]*" '/^[ \t]*DBPath[ \t]*=/{gsub(/[ \t]*$/, "", $2); print $2}' /etc/pacman.conf 2>/dev/null)" 138 | [ -z "$DBPath" ] && DBPath="/var/lib/pacman" 139 | 140 | if [ ! -d "$DBPath/local/" ]; then 141 | error "Could not find local database in $DBPath/local/." 142 | exit 1 143 | fi 144 | 145 | awk 'BEGIN { 146 | split("B KiB MiB GiB TiB PiB EiB ZiB YiB", unit) 147 | } 148 | $0 == "%NAME%" { 149 | getline pkg 150 | } 151 | $0 == "%SIZE%" { 152 | getline size 153 | i = 1 154 | while (size > 2048) { 155 | size /= 1024 156 | i++ 157 | } 158 | printf ("%4d%-3s %s\n", size, unit[i], pkg) 159 | }' "$DBPath"/local/*/desc | { $opt_sort || cat ;} | { $opt_total || cat ;} 160 | exit 161 | fi 162 | 163 | ## Per-package mode. 164 | if [ $# -eq 0 ]; then 165 | error "Missing argument." 166 | usage 167 | exit 1 168 | fi 169 | 170 | ## Remove this check if integrated to pacman. 171 | if ! command -v pacman >/dev/null 2>&1; then 172 | error "'pacman' not found" 173 | exit 1 174 | fi 175 | 176 | { 177 | ## If package is not found locally (-Q), we use the sync database (-S). We 178 | ## use LC_ALL=C to make sure pacman output is not localized. 179 | buffer=$(LC_ALL=C pacman -Qi "$@" 2>&1 1>&3 3>&- | cut -f2 -d "'") 180 | [ -n "$buffer" ] && LC_ALL=C pacman -Si "$buffer" 181 | } 3>&1 | filter | { $opt_sort || remove_duplicates ;} | { $opt_total || cat ;} 182 | -------------------------------------------------------------------------------- /.local/bin/pdfctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} COMMAND [-i] [-o OUTPUT] [OPTIONS] FILES... 6 | 7 | Wrapper around various PDF operations. 8 | OUTPUT is ignored when processing in-place (-i) or when more than one input 9 | files is given. 10 | Otherwise, or if OUTPUT is unspecified, a file with a random suffix is produced. 11 | 12 | List of commands and their options: 13 | 14 | compress [OPTIONS] 15 | Compress PDFs. 16 | -c: Compress raster graphics at the expense of a quality loss. 17 | -n: Do not compress raster graphics at all. Output may be bigger. 18 | 19 | extract [-f FIRST-PAGE] [-l LAST-PAGE] 20 | Extract a range of pages to a single PDF. 21 | 22 | resize 23 | Resize to A4. 24 | 25 | size 26 | Same as pdfinfo, but append size in milimeters. 27 | 28 | xerox 29 | Convert a PDF to a blurred, black & white raster image. 30 | 31 | 32 | For more details on compression: 33 | 34 | $ gs -sDEVICE=pdfwrite -o /dev/null \\ 35 | -c "currentpagedevice { exch ==only ( ) print == } forall" 36 | 37 | http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/DistillerParameters.pdf 38 | 39 | EOF 40 | } 41 | 42 | [ $# -eq 0 ] && usage && exit 43 | 44 | cmd="$1" 45 | shift 1 46 | 47 | NO_OUTPUT=false 48 | INPLACE=false 49 | 50 | COMPRESS_OPT="-dColorConversionStrategy=/LeaveColorUnchanged -dDownsampleMonoImages=false -dDownsampleGrayImages=false -dDownsampleColorImages=false -dAutoFilterColorImages=false -dAutoFilterGrayImages=false -dColorImageFilter=/FlateEncode -dGrayImageFilter=/FlateEncode" 51 | 52 | EXTRACT_FIRST=1 53 | EXTRACT_LAST=1 54 | 55 | case $cmd in 56 | compress) 57 | while getopts ":cino:" opt; do 58 | case $opt in 59 | c) 60 | COMPRESS_OPT="" ;; 61 | i) 62 | INPLACE=true ;; 63 | n) 64 | COMPRESS_OPT="-dColorConversionStrategy=/LeaveColorUnchanged -dEncodeColorImages=false -dEncodeGrayImages=false -dEncodeMonoImages=false" ;; 65 | o) 66 | output="$OPTARG" ;; 67 | \?) 68 | usage 69 | exit 1 ;; 70 | esac 71 | done 72 | ;; 73 | 74 | extract) 75 | while getopts ":f:il:o:" opt; do 76 | case $opt in 77 | f) 78 | EXTRACT_FIRST="$OPTARG" ;; 79 | i) 80 | INPLACE=true ;; 81 | l) 82 | EXTRACT_LAST="$OPTARG" ;; 83 | o) 84 | output="$OPTARG" ;; 85 | \?) 86 | usage 87 | exit 1 ;; 88 | esac 89 | done 90 | ;; 91 | 92 | resize|xerox) 93 | while getopts ":io:" opt; do 94 | case $opt in 95 | i) 96 | INPLACE=true ;; 97 | o) 98 | output="$OPTARG" ;; 99 | \?) 100 | usage 101 | exit 1 ;; 102 | esac 103 | done 104 | ;; 105 | 106 | size) 107 | NO_OUTPUT=true ;; 108 | 109 | *) 110 | usage 111 | exit 1 ;; 112 | esac 113 | 114 | shift $((OPTIND - 1)) 115 | if [ $# -eq 0 ]; then 116 | usage 117 | exit 1 118 | fi 119 | [ $# -gt 1 ] && unset output 120 | 121 | mkoutput () { 122 | if [ -z "$output" ] || [ -e "$output" ]; then 123 | case "$input" in 124 | */*) ;; 125 | *) input="./$input" ;; 126 | esac 127 | dirname="${input%/*}" 128 | basename="${input##*/}" 129 | output=$(mktemp "$dirname/${basename%.*}-$cmd"-XXXXXX.pdf) 130 | fi 131 | echo "$output" 132 | } 133 | 134 | ## Some JPEG options 135 | # -sDEVICE=jpeg 136 | # -dUseCIEColor 137 | # -dJPEGQ=100 138 | # -r300 139 | # -dTextAlphaBits=4 140 | # -dGraphicsAlphaBits=4 141 | # -dMaxStripSize=8192 142 | compress () { 143 | gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite $COMPRESS_OPT -sOutputFile="$output" "$input" 144 | } 145 | 146 | extract () { 147 | gs -sDEVICE=pdfwrite -dNOPAUSE -dSAFER -dBATCH -dFirstPage="$EXTRACT_FIRST" -dLastPage="$EXTRACT_LAST" -sOutputFile="$output" "$input" 148 | } 149 | 150 | resize () { 151 | gs -q -o "$output" -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage -dCompatibilityLevel=1.4 "$input" 152 | } 153 | 154 | size () { 155 | pdfinfo "$input" | awk '/^Page size:/ {printf $0; print ", " $3*0.35278 " x " $5*0.35278 " mm"; next } 1' 156 | } 157 | 158 | xerox () { 159 | convert -threshold 90% -blur 1x1 -quality 100 -flatten -density 400 "$input" "$output" 160 | } 161 | 162 | for input; do 163 | echo "==> '$input'" 164 | $NO_OUTPUT || output=$(mkoutput) 165 | $cmd 166 | if $INPLACE; then 167 | rm -f "$input" 168 | mv "$output" "$input" 169 | fi 170 | echo 171 | done 172 | -------------------------------------------------------------------------------- /.local/bin/pkglister: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## Create lists of system- and TeX Live packages. 4 | 5 | ## Variables 6 | PKG_ROOT="$HOME/.pkglists" 7 | mkdir -p "$PKG_ROOT" 8 | 9 | ## Arch Linux 10 | if command -v pacman >/dev/null 2>&1; then 11 | pacman -Qneq | LC_ALL=C sort >"$PKG_ROOT/arch-official" 12 | pacman -Qmeq | LC_ALL=C sort >"$PKG_ROOT/arch-aur" 13 | fi 14 | 15 | ## TeXlive 16 | if ! command -v guix >/dev/null 2>&1; then 17 | if command -v tlmgr >/dev/null 2>&1; then 18 | tlctl l >"$PKG_ROOT/texlive" 19 | fi 20 | fi 21 | 22 | ## Guix 23 | if command -v guix >/dev/null 2>&1; then 24 | cat<"$PKG_ROOT/guix" 25 | (specifications->manifest 26 | '( 27 | EOF 28 | guix package -I | awk '{printf("\"%s", $1); if($3!="out") {printf("%s", ":" $3)}; print "\""}' | LC_ALL=C sort >>"$PKG_ROOT/guix" 29 | echo "))" >>"$PKG_ROOT/guix" 30 | fi 31 | -------------------------------------------------------------------------------- /.local/bin/preview: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FILES 6 | 7 | Preview FILES: 8 | 9 | - If folder, list it. 10 | 11 | - For text files, media files and other files supported by ranger's "scope.sh", 12 | use the script to preview the file. 13 | 14 | - For other files, display some file information. 15 | 16 | EOF 17 | } 18 | 19 | [ $# -lt 1 ] && usage && return 1 20 | [ "$1" = "-h" ] && usage && return 21 | [ "$1" = "--" ] && shift 22 | 23 | ls="ls -1 --color=always" 24 | if test -t 0; then 25 | ls="$ls --indicator-style=classify" 26 | fi 27 | if [ "$(uname -o)" = "GNU/Linux" ]; then 28 | ls="$ls --group-directories-first" 29 | fi 30 | 31 | ## scope.sh. 32 | XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-~/.config} 33 | scope="$XDG_CONFIG_HOME/ranger/scope.sh" 34 | if [ ! -x "$scope" ]; then 35 | XDG_DATA_DIRS=${XDG_DATA_DIRS:-"/usr/local/share"} 36 | scope="$XDG_DATA_DIRS/doc/ranger/config/scope.sh" 37 | if [ ! -x "$scope" ]; then 38 | scope="/usr/share/doc/ranger/config/scope.sh" 39 | fi 40 | fi 41 | 42 | ## Several files must share the screen space. 43 | lines=$(expr $(tput lines) / $#) 44 | [ $lines -lt 1 ] && lines=1 45 | 46 | _preview() { 47 | ## Folders. 48 | [ -d "$1" ] && $ls "$1" && return 49 | 50 | buf=$("$scope" "$1" $(tput cols) $lines 2>/dev/null) 51 | status=$? 52 | 53 | case $status in 54 | 1) 55 | break ;; 56 | 2) 57 | ## Text files 58 | sed ${lines}q "$1" 59 | return ;; 60 | *) 61 | echo "$buf" | sed ${lines}q 62 | return ;; 63 | esac 64 | 65 | ## All files. 66 | path="$1" 67 | [ ! -e "$path" ] && path=$(command -v "$1") 68 | [ ! -e "$path" ] && return 69 | $ls -l "$path" 70 | file "$path" | cut -d':' -f2 | cut -b 2- 71 | if command -v pacman >/dev/null 2>&1; then 72 | pacman -Qo "$path" 2>/dev/null 73 | fi 74 | } 75 | 76 | [ $# -eq 1 ] && _preview "$1" && exit 77 | 78 | for i; do 79 | ## GNU head uses this echo when outputting multiple files. 80 | echo "==> $i <==" 81 | _preview "$i" 82 | done 83 | -------------------------------------------------------------------------------- /.local/bin/probe: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FILE 6 | ${0##*/} ENTRIES FILE 7 | 8 | Run ffprobe on FILE using shell print format. If no entry is specified, print 9 | format and streams. 10 | 11 | EOF 12 | } 13 | 14 | [ $# -eq 0 ] && usage && exit 1 15 | [ "$1" = "-h" ] && usage && exit 16 | [ "$1" = "--" ] && shift 17 | 18 | if [ $# -gt 1 ]; then 19 | ffprobe -v quiet -print_format flat=s=_ -show_entries -- "$@" 20 | else 21 | ffprobe -v quiet -print_format flat=s=_ -show_format -show_streams -- "$1" 22 | fi 23 | -------------------------------------------------------------------------------- /.local/bin/rcopy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} SOURCE... DEST 6 | 7 | Use rsync to copy SOURCE to DEST while showing progress and allowing resuming. 8 | 9 | SOURCE can be multiple files or folder. A trailing slash in a source folder will 10 | copy the content of it, not the folder itself. If DEST does not exist, it will 11 | be created. If DEST has files not present in SOURCE, they will remain untouched. 12 | 13 | EOF 14 | } 15 | 16 | [ $# -lt 2 ] && usage && exit 1 17 | [ "$1" = "-h" ] && usage && exit 18 | [ "$1" = "--" ] && shift 19 | 20 | rsync -livr --append-verify --progress -- "$@" 21 | -------------------------------------------------------------------------------- /.local/bin/rdiff: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] DIR1 DIR2 6 | 7 | Use rsync to display a folder tree diff between DIR1 and DIR2. 8 | 9 | Additional rsync OPTIONS can be used, such as '-t, --times'. 10 | Lookup '-i, --itemize-changes' in rsync(1) for the legend. 11 | EOF 12 | } 13 | 14 | [ $# -lt 2 ] && usage && exit 1 15 | [ "$1" = "-h" ] && usage && exit 16 | [ "$1" = "--" ] && shift 17 | 18 | rsync -nivr -lpgod --delete --size-only "$@" 19 | -------------------------------------------------------------------------------- /.local/bin/realpath: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## This is a compatibility wrapper for 'realpath'. This script is not seen if 3 | ## the parent folder is after /usr/{local/}bin in PATH. 4 | 5 | if command -v greadlink >/dev/null 2>&1; then 6 | ## On BSD systems, we might have greadlink 7 | greadlink -f "$@" 8 | elif command -v readlink >/dev/null 2>&1 && [ "$(uname)" = "Linux" ]; then 9 | readlink -f "$@" 10 | else 11 | ## Dirty fallback 12 | echo "$@" 13 | fi 14 | -------------------------------------------------------------------------------- /.local/bin/renamelower: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FILES 6 | 7 | Rename FILES to lowercase if destination does not exist. 8 | 9 | EOF 10 | } 11 | 12 | [ $# -eq 0 ] && usage && exit 1 13 | [ "$1" = "-h" ] && usage && exit 14 | [ "$1" = "--" ] && shift 15 | 16 | for f ; do 17 | filename=${f##*/} 18 | 19 | case "$f" in 20 | */*) dirname="${f%/*}" ;; 21 | *) dirname="." ;; 22 | esac 23 | 24 | nf="$(echo "$filename" | awk '{print tolower($0)}')" 25 | [ "$nf" = "$filename" ] && continue 26 | newname="${dirname}/${nf}" 27 | mv -nv "$f" "$newname" 28 | done 29 | -------------------------------------------------------------------------------- /.local/bin/renameswap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FILE1 FILE2 6 | 7 | Swap 2 filenames around. 8 | 9 | EOF 10 | } 11 | 12 | [ $# -ne 2 ] && usage && exit 1 13 | [ "$1" = "-h" ] && usage && exit 14 | [ "$1" = "--" ] && shift 15 | 16 | ## We need a temp file is case both files are in the same folder. We use the 17 | ## unsecure option since we do not want to create an empty file in 18 | ## advance. Indeed, creating a file with mktemp is problematic for folders since 19 | ## non-GNU mv can only move _into_ an existing folder. But we do not overwrite 20 | ## if file exists. 21 | TEMPFILE="$(mktemp -u "$1.XXXXXX")" 22 | 23 | case "$1" in 24 | */*) DIR1="${1%/*}" ;; 25 | *) DIR1="." ;; 26 | esac 27 | case "$2" in 28 | */*) DIR2="${2%/*}" ;; 29 | *) DIR2="." ;; 30 | esac 31 | 32 | if ! mv -n "$1" "$TEMPFILE"; then 33 | echo >&2 "Cannot move to temporary file '$TEMPFILE' (maybe try again)" 34 | fi 35 | ## We need to specify the directories because of non-uniform behaviour across 36 | ## the various 'mv' implementations. 37 | mv -n "$2" "$DIR2/${1##*/}" 38 | mv -n "$TEMPFILE" "$DIR1/${2##*/}" 39 | -------------------------------------------------------------------------------- /.local/bin/replace: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] SEARCH REPLACE [FILES] 6 | 7 | Replace SEARCH by REPLACE in FILES. If no file is provided, use stdin. 8 | Backslashes are interpreted in SEARCH and REPLACE (e.g. \n, \t). If you want to 9 | inhibit this behaviour, you need to double them. 10 | 11 | Options: 12 | 13 | -h: Show this help. 14 | -i: Replace file content instead of printing to stdout. 15 | 16 | EOF 17 | } 18 | 19 | OPT_INPLACE="" 20 | while getopts ":ih" opt; do 21 | case $opt in 22 | i) 23 | OPT_INPLACE=-i ;; 24 | h) 25 | usage 26 | exit 1 ;; 27 | \?) 28 | usage 29 | exit 1 ;; 30 | esac 31 | done 32 | 33 | shift $((OPTIND - 1)) 34 | 35 | if [ $# -lt 2 ]; then 36 | usage 37 | exit 1 38 | fi 39 | 40 | search="$1" 41 | replace="$2" 42 | shift 2 43 | 44 | replace () { 45 | ## We cannot use gsub, otherwise regex substitutions could occur. 46 | ## Source: http://mywiki.wooledge.org/BashFAQ/021 47 | awk -v s="$search" -v r="$replace" 'BEGIN {l=length(s)} {o="";while (i=index($0, s)) {o=o substr($0,1,i-1) r; $0=substr($0,i+l)} print o $0}' "$@" 48 | } 49 | 50 | if [ $# -eq 0 ] || [ -z "$OPT_INPLACE" ]; then 51 | replace "$@" 52 | else 53 | for i ; do 54 | out="$(mktemp "$i.XXXXXX")" 55 | replace "$i" > "$out" 56 | mv "$out" "$i" 57 | done 58 | fi 59 | -------------------------------------------------------------------------------- /.local/bin/rmirror: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} SOURCE DEST 6 | 7 | Use rsync to mirror SOURCE to DEST while showing progress. 8 | SOURCE does not need to be ending with a trailing slash. Only size is used for 9 | comparison. File perms and dates are mirrored. 10 | 11 | A dry-run is made by default. 12 | 13 | Options: 14 | 15 | -p: Process. 16 | 17 | EOF 18 | } 19 | 20 | opt_dry="-n" 21 | if [ "$1" = "-p" ]; then 22 | opt_dry="" 23 | shift 24 | fi 25 | 26 | [ $# -ne 2 ] && usage && exit 1 27 | [ "$1" = "-h" ] && usage && exit 28 | [ "$1" = "--" ] && shift 29 | 30 | ## We use archive mode '-a' which preserves perms and dates. On non-POSIX 31 | ## filesystems, you might want to skip this and preserve symlinks only by 32 | ## replacing -a with -lr. 33 | rsync $opt_dry -iv -a --size-only --delete --exclude="/lost+found" --progress -- "$1"/ "$2" 34 | -------------------------------------------------------------------------------- /.local/bin/sanitize: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FOLDERS 6 | 7 | Set file/directory owner and permissions according to current umask for current 8 | user. 9 | 10 | EOF 11 | } 12 | 13 | [ $# -eq 0 ] && usage && exit 1 14 | [ "$1" = "-h" ] && usage && exit 15 | [ "$1" = "--" ] && shift 16 | 17 | FMASK=$(umask -S | sed 's/x//g') 18 | DMASK=$(umask -S) 19 | [ -z "$UID" ] && UID=$(id -u) 20 | [ -z "$GID" ] && GID=$(id -g) 21 | 22 | for i ; do 23 | find "$i" -exec chown -R "$UID:$GID" {} \; 24 | find "$i" -type d -exec chmod "$DMASK" {} \; 25 | find "$i" -type f -exec chmod "$FMASK" {} \; 26 | done 27 | -------------------------------------------------------------------------------- /.local/bin/scanner: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Sample script for A3 scanner. It selects a scan area of A4, then converts the 6 | result to png while rotating the image apropriately. The date and time is 7 | appended to the output filename which is in the current folder. 8 | EOF 9 | exit 10 | fi 11 | 12 | scanimage -x 297 -y 210 | convert -rotate 90 - "scan-$(date "+%F_%T").png" 13 | -------------------------------------------------------------------------------- /.local/bin/strip-comments: -------------------------------------------------------------------------------- 1 | #!/usr/bin/awk -f 2 | 3 | ## Default to C block comments. You can change the comment delimiters from 4 | ## command line. The delims are regexes. For instance call this script with 5 | ## 6 | ## awk -v begin="#" -v end="$" -f 7 | ## 8 | ## to use shell comment delimiters. 9 | 10 | BEGIN { 11 | ## Since 'begin' and 'end' are regexes, we need to escape some sequences. 12 | if(begin == "") 13 | begin="/\\*" 14 | if(end == "") 15 | end="\\*/" 16 | } 17 | 18 | { 19 | while (match ($0, begin)) { 20 | before = substr ($0, 1, RSTART-1) 21 | $0 = substr($0, RSTART) 22 | printf("%s", before) 23 | 24 | ## Reach line where first 'end' is found. 25 | while (! match($0, end) ) 26 | getline 27 | 28 | $0 = substr($0, RSTART + length(end) -1) 29 | } 30 | print 31 | } 32 | -------------------------------------------------------------------------------- /.local/bin/tc-video-custom: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OUTPUT_NAME="tc-video" 4 | 5 | usage () { 6 | cat <&2 7 | Usage: ${0##*/} [FILES] 8 | 9 | Create a '$OUTPUT_NAME' script in current folder. The script provides a FFmpeg call 10 | to transcode FILES with some useful options and instructive help. 11 | 12 | This script is meant to be easily editable to fit the user needs. 13 | 14 | EOF 15 | } 16 | 17 | [ $# -eq 0 ] && usage && exit 1 18 | [ "$1" = "-h" ] && usage && exit 19 | [ "$1" = "--" ] && shift 20 | 21 | escname () { 22 | echo "$@" | sed 's|/|\\/|g' 23 | } 24 | 25 | SCRIPT_PATH="${0%/*}" 26 | SCRIPT_NAME="${0##*/}" 27 | FILELIST="" 28 | if [ -f "$SCRIPT_PATH/.$SCRIPT_NAME.in" ]; then 29 | cp -i "$SCRIPT_PATH/.$SCRIPT_NAME.in" "$OUTPUT_NAME" 30 | for i ; do 31 | esci="$(escname "$i")" 32 | FILELIST="${FILELIST:+$FILELIST -i }'$esci'" 33 | ex -sc "%s/###FILENAMES/'$esci' ###FILENAMES/ | xit" "$OUTPUT_NAME" 34 | done 35 | ex -sc '%s/###FILELIST/'"$FILELIST"'/ | xit' "$OUTPUT_NAME" 36 | chmod +x "$OUTPUT_NAME" 37 | else 38 | echo ".$SCRIPT_NAME.in not found" 39 | fi 40 | -------------------------------------------------------------------------------- /.local/bin/termctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} QUERY 6 | 7 | Perform one of the terminal QUERIES: 8 | 9 | idx: 10 | Print color indices. 11 | lines: 12 | Print 256 colored lines. 13 | list: 14 | List color support for all terminals. 15 | prop: 16 | Print the properties of the current terminal. 17 | 18 | EOF 19 | } 20 | 21 | [ $# -eq 0 ] && usage && exit 1 22 | [ "$1" = "-h" ] && usage && exit 23 | [ "$1" = "--" ] && shift 24 | 25 | idx () { 26 | # The test text. Must be 3 letters. 27 | local T 28 | T='Doh' 29 | 30 | printf "\n 40m 41m 42m 43m\ 31 | 44m 45m 46m 47m\n"; 32 | 33 | for FG in m 1m 30m '1;30m' 31m '1;31m' 32m '1;32m' 33m '1;33m' 34m '1;34m' \ 34 | 35m '1;35m' 36m '1;36m' 37m '1;37m' ; do 35 | FGs=$(printf '%5s' "$FG") 36 | echo -en " $FGs \033[$FG $T " 37 | for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do 38 | echo -en "$EINS \033[$FG\033[$BG $T \033[0m"; 39 | done 40 | echo 41 | done 42 | echo 43 | } 44 | 45 | lines () { 46 | local op line index 47 | op=$(tput op) 48 | line=$(printf '%76s' | sed 's/ /=/g') 49 | for i in {0..256}; do 50 | index=$(printf '%03d' $i) 51 | echo -e "$index $(tput setaf $i;tput setab $i)$line$op" 52 | done 53 | } 54 | 55 | list () { 56 | for T in $(find "/usr/share/terminfo" -type f -printf '%f\n'); do 57 | echo "$T $(tput -T $T colors)" 58 | done | sort -nk2 59 | } 60 | 61 | prop () { 62 | infocmp -1 | sed -nu 's/^[ \000\t]*//;s/[ \000\t]*$//;/[^ \t\000]\{1,\}/!d;/acsc/d;s/=.*,//p'| column -c80 63 | } 64 | 65 | case "$1" in 66 | idx) 67 | idx ;; 68 | lines) 69 | lines ;; 70 | list) 71 | list ;; 72 | prop) 73 | prop ;; 74 | *) 75 | usage;; 76 | esac 77 | -------------------------------------------------------------------------------- /.local/bin/texclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FILES.tex|FILES.texi 6 | 7 | Clean TeX/LaTeX/Texinfo projects of temp files. 8 | 9 | Argument must have a '.tex' or '.texi' extension so that we do not acccidentally 10 | remove files matching these extensions if they are not related to a TeX file. 11 | 12 | EOF 13 | } 14 | 15 | [ $# -eq 0 ] && usage && exit 1 16 | [ "$1" = "-h" ] && usage && exit 17 | [ "$1" = "--" ] && shift 18 | 19 | for i ; do 20 | case "$i" in 21 | */*) ;; 22 | *) 23 | i="./$i" ;; 24 | esac 25 | dirname="${i%/*}" 26 | basename="${i##*/}" 27 | ext=$(echo "${basename##*.}" | awk '{print tolower($0)}') 28 | basename="${basename%.*}" 29 | [ "$ext" != "tex" ] && [ "$ext" != "texi" ] && continue 30 | ## Reset arg list (big performance boost). 31 | set -- 32 | for j in aux bbl blg cp cps fn glg glo gls idx ilg ind ky lof log maf mt mtc nav out pg snm synctex.gz synctex tns toc tp vr vrs xdy 33 | do 34 | set -- "$@" "$dirname/$basename.$j" 35 | done 36 | ## Do the file check last to minimize race conditions. 37 | [ -f "$i" ] || continue 38 | rm -v "$@" 2>/dev/null 39 | done 40 | -------------------------------------------------------------------------------- /.local/bin/tlctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} COMMAND [PACKAGES] 6 | 7 | Wrapper around essential features of 'tlmgr' TeXlive manager. 8 | 9 | List of commands: 10 | 11 | f: Search files. 12 | i: Install packages. 13 | l List installed packages. 14 | q Query info about package. 15 | r: Remove packages. 16 | s: Search packages. 17 | u: Update tlmgr. 18 | EOF 19 | } 20 | 21 | [ $# -eq 0 ] && usage && exit 1 22 | 23 | 24 | if ! command -v tlmgr >/dev/null 2>&1; then 25 | echo 'tlmgr not found' 26 | exit 1 27 | fi 28 | 29 | command="$1" 30 | shift 1 31 | 32 | ## It is important to set umask properly, otherwise users might not have 33 | ## authorization to use the packages. 34 | case "$command" in 35 | f) 36 | tlmgr search --global --file "$@" ;; 37 | h) 38 | usage ;; 39 | i) 40 | sudo sh -c 'umask 022 && tlmgr install $0 "$@"' "$@" ;; 41 | l) 42 | ## Note: We use in the sed expressions. 43 | TEXLIVE_BASIC="$(mktemp)" 44 | tlmgr info collection-basic --list | sed -n '/^ /{s/ //g;p;}' | LC_ALL=C sort >"$TEXLIVE_BASIC" 45 | 46 | TEXLIVE_ALL="$(mktemp)" 47 | tlmgr info --only-installed | grep -v 'x86_64\|amd64' | cut -d' ' -f2 | cut -f1 -d':' | LC_ALL=C sort >"$TEXLIVE_ALL" 48 | 49 | LC_ALL=C comm -3 "$TEXLIVE_BASIC" "$TEXLIVE_ALL" | sed 's/ //g' | \ 50 | grep -vi 'collection-basic\|scheme-minimal\|texlive-common\|texlive-docindex\|texlive-en' 51 | 52 | rm "$TEXLIVE_ALL" "$TEXLIVE_BASIC" 53 | ;; 54 | q) 55 | ## First query locally, then online db if needed. 56 | buf=$(tlmgr info --list --only-installed "$@") 57 | installed=$(echo "$buf" | awk '$1 == "package:" {firstline=$0; getline; if($1!="category:") next; else print firstline } 1') 58 | echo "$installed" 59 | missing=$(echo "$buf" | awk '$1 == "package:" {pkg=$2; getline; if($1!="category:") print pkg}') 60 | [ -n "$missing" ] && tlmgr info --list "$missing" 61 | ;; 62 | r) 63 | sudo sh -c 'umask 022 && tlmgr remove $0 "$@"' "$@" ;; 64 | s) 65 | tlmgr search --global "$@" ;; 66 | u) 67 | sudo sh -c 'umask 022 && tlmgr update --self' ;; 68 | *) 69 | echo "wrong command '$command'" 70 | usage 71 | exit 1 ;; 72 | esac 73 | 74 | exit $? 75 | -------------------------------------------------------------------------------- /.local/bin/transfer: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## Adapted from https://gist.github.com/nl5887/a511f172d3fb3cd0e42d. 3 | 4 | # 5 | # Defines transfer alias and provides easy command line file and folder sharing. 6 | # 7 | # Authors: 8 | # Remco Verhoef 9 | # 10 | 11 | curl --version 2>&1 > /dev/null 12 | if [ $? -ne 0 ]; then 13 | echo "Could not find curl." 14 | exit 1 15 | fi 16 | 17 | # check arguments 18 | if [ $# -eq 0 ]; 19 | then 20 | cat<> $zipfile 50 | curl --progress-bar --upload-file "$zipfile" "https://transfer.sh/$basefile.zip" >> $tmpfile 51 | rm -f $zipfile 52 | else 53 | # transfer file 54 | curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile 55 | fi 56 | else 57 | # transfer pipe 58 | curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile 59 | fi 60 | 61 | # cat output link 62 | cat $tmpfile 63 | 64 | # cleanup 65 | rm -f $tmpfile 66 | -------------------------------------------------------------------------------- /.local/bin/transmission-auto: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] 6 | 7 | With no argument, open Transmission's interface. Otherwise, run 8 | transmission-remote with the provided options. 9 | 10 | In both cases if transmission-daemon is not running it will be started 11 | beforehand. 12 | 13 | EOF 14 | exit 15 | fi 16 | 17 | for i in transmission-daemon transmission-remote ; do 18 | if ! command -v $i >/dev/null 2>&1; then 19 | echo >&2 "'$i' not found" 20 | exit 1 21 | fi 22 | done 23 | 24 | ## The command is often displayed as transmission-da. 25 | ## The 'sleep' is needed here to give the daemon some time to start. 1 sec 26 | ## should be enough on most system. 27 | ps -U "$USER" -o comm= | grep -q transmission-da || { transmission-daemon && echo "Daemon started" && sleep 1 ; } 28 | 29 | if [ $# -eq 0 ]; then 30 | $BROWSER http://localhost:9091/ 31 | else 32 | transmission-remote "$@" 33 | fi 34 | -------------------------------------------------------------------------------- /.local/bin/udisks-automount: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} 6 | 7 | Automatically mount external drives 'udisksctl'. 8 | 9 | From https://wiki.archlinux.org/index.php/Udisks#udevadm_monitor. 10 | 11 | EOF 12 | exit 13 | fi 14 | 15 | pathtoname() { 16 | udevadm info -p /sys/"$1" | awk -v FS== '/DEVNAME/ {print $2}' 17 | } 18 | 19 | stdbuf -oL -- udevadm monitor --udev -s block | while read -r -- _ _ event devpath _; do 20 | if [ "$event" = add ]; then 21 | devname=$(pathtoname "$devpath") 22 | udisksctl mount --block-device "$devname" --no-user-interaction 23 | fi 24 | done 25 | -------------------------------------------------------------------------------- /.local/bin/updatedb-local: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | HOME_DB_FOLDER="$HOME/.cache" 4 | DB_FILE="locate.db" 5 | 6 | if [ "$1" = "-h" ]; then 7 | cat <&2 8 | Usage: ${0##*/} [FOLDERS] 9 | 10 | Update the 'locate' databases for the home folder, external drives and the FOLDERS arguments. 11 | 12 | For external drives, databases are only updated if found, they are not 13 | automatically created (unless explicitly specified in the FOLDERS arguments). 14 | 15 | - The database for the home folder is store in '$HOME_DB_FOLDER/$DB_FILE'. 16 | - Other databases are stored in '$MEDIA_DB' at the target root. 17 | 18 | EOF 19 | exit 20 | fi 21 | 22 | update() { 23 | [ $# -ne 2 ] && set -- "$1" "$1/locate.db" 24 | echo >&2 "Updating '$2' database for '$1'..." 25 | ## From https://git.archlinux.org/svntogit/packages.git/tree/trunk/updatedb.conf?h=packages/mlocate. 26 | updatedb -l 0 -o "$2" -U "$1" \ 27 | --prune-bind-mounts=1 \ 28 | --prunefs="9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset cramfs debugfs devpts devtmpfs ecryptfs exofs ftpfs fuse fuse.encfs fuse.sshfs fusectl gfs gfs2 hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs shfs smbfs sockfs sshfs sysfs tmpfs ubifs udf usbfs vboxsf" \ 29 | --prunepaths="/gnu/store /afs /mnt /net /sfs /tmp /udev /var/cache /var/lib/pacman/local /var/lock /var/run /var/spool /var/tmp" \ 30 | --prunenames=".git .hg .svn .cache Trash .Trash-$(id -u)" 31 | } 32 | 33 | update "/" "$HOME_DB_FOLDER/$DB_FILE" 34 | 35 | ## Only update external media databases. 36 | for i in "/run/media/$USER"/* "/media/$USER"/*; do 37 | [ -f "$i/$DB_FILE" ] && update "$i" 38 | done 39 | 40 | if [ ! -d "/media/$USER" ]; then 41 | for i in "/media"/*; do 42 | [ -f "$i/$DB_FILE" ] && update "$i" 43 | done 44 | fi 45 | 46 | ## Create database for the specified folders. 47 | for i; do 48 | [ -d "$i" ] && update "$i" 49 | done 50 | -------------------------------------------------------------------------------- /.local/bin/utf8fy: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} FILES... 6 | 7 | Convert all "badly" encoded text files to UTF-8/LF without BOM. 8 | 9 | EOF 10 | } 11 | 12 | [ $# -eq 0 ] && usage && exit 1 13 | [ "$1" = "-h" ] && usage && exit 14 | [ "$1" = "--" ] && shift 15 | 16 | for i ; do 17 | [ ! -f "$i" ] && continue 18 | mimetype=$(file -bi "$i") 19 | description=$(file -b "$i") 20 | type=$(echo "$mimetype" | awk -F/ '{print $1}') 21 | [ "$type" != text ] && continue 22 | 23 | charset=$(echo "$mimetype" | awk -F "=" '{print $2}') 24 | if [ "$charset" != utf-8 ]; then 25 | echo "$i: Convert to UTF-8" 26 | iconv -f "$charset" -t utf8 "$i" -o "$i" 27 | fi 28 | 29 | if echo "$description" | grep -q 'UTF-8 Unicode (with BOM)'; then 30 | echo "$i: Remove BOM" 31 | ex -sc '1s/^.//|xit' "$i" 32 | ## Interesting alternatives: 33 | # dd iflag=skip_bytes skip=3 if=file.srt of=temp.srt 34 | # dd bs=1 skip=3 if=file.srt of=temp.srt 35 | # tail -c +32 file.srt > temp.srt 36 | fi 37 | 38 | if echo "$description" | grep -q 'CRLF'; then 39 | echo "$i: Remove CR" 40 | ex -sc '%s/ //g|xit' "$i" 41 | fi 42 | done 43 | -------------------------------------------------------------------------------- /.local/bin/weather: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "$1" = "-h" ]; then 4 | cat <&2 5 | Usage: ${0##*/} [OPTIONS] 6 | 7 | Display weather forecast. 8 | 9 | Use '${0##*/} :help' to list all options. 10 | 11 | EOF 12 | exit 13 | fi 14 | 15 | curl wttr.in/"$1" 16 | -------------------------------------------------------------------------------- /.local/bin/winefps: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} WIN_EXE PARAMS" 6 | 7 | Run Wine application while displaying FPS onscreen. 8 | 9 | EOF 10 | } 11 | 12 | [ $# -eq 0 ] && usage && exit 1 13 | [ "$1" = "-h" ] && usage && exit 14 | [ "$1" = "--" ] && shift 15 | 16 | if ! command -v osd_cat >/dev/null 2>&1; then 17 | echo >&2 "osd_cat not found" 18 | exit 1 19 | fi 20 | 21 | ## The unbuffered option is -u on GNU and OpenBSD, -l on others. 22 | OPT_UNBUF=-l 23 | case "$(uname)" in 24 | Linux|OpenBSD) OPT_UNBUF=-u ;; 25 | esac 26 | 27 | WINEDEBUG=fps wine "$@" 2>&1 | tee /dev/stderr | \ 28 | sed $OPT_UNBUF -n '/^trace:fps:/{s/.* \([^ ]*\)fps/\1/;p}' | \ 29 | osd_cat -l1 -f "-*-*-*-*-*-*-32-*-*-*-*-*-*-*" -O1 -c "yellow" 30 | -------------------------------------------------------------------------------- /.local/bin/worldtime: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -- \ 4 | UTC '' \ 5 | Europe/Paris "France Germany Sweden" \ 6 | Asia/Calcutta India \ 7 | Indian/Mauritius Mauritius \ 8 | Africa/Tunis Tunisia \ 9 | Asia/Ho_Chi_Minh Vietnam \ 10 | Australia/Melbourne Melbourne \ 11 | Africa/Nairobi Uganda \ 12 | 13 | while [ $# -gt 0 ]; do 14 | TZ="$1" date "+%a %b %e %H:%M:%S %Z %Y%t$2" 15 | shift 2 16 | done 17 | -------------------------------------------------------------------------------- /.local/bin/xctl: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage () { 4 | cat <&2 5 | Usage: ${0##*/} [OPERATION] 6 | 7 | When no OPERATION is specified, reset the screen to the defaults. 8 | 9 | Apply OPERATION to the X screen renderer: 10 | 11 | multi VIDEOPORT 12 | starwars 13 | zoomin 14 | zoomout 15 | 16 | EOF 17 | } 18 | 19 | current=$(xrandr | sed -n "/current/{n;p;q}" | cut -f1 -d" ") 20 | ## Other unreliable options: 21 | # xrandr | grep -m1 "\" | cut -f1 -d" " 22 | # xrandr | awk 'NR==2 {print $1; exit}' 23 | 24 | if [ $# -eq 0 ]; then 25 | xrandr --output "$current" --auto --transform none --brightness 1 && \ 26 | xrandr -s "$(xrandr | awk '/^ / {print $1;exit}')" 27 | exit 28 | fi 29 | 30 | case "$1" in 31 | multi) 32 | [ $# -lt 2 ] && usage && exit 1 33 | xrandr --output "$2" --auto --right-of "$current" ;; 34 | starwars) 35 | xrandr --output "$current" --transform 1.24,0.16,-124,0,1.24,0,0,0.000316,1 ;; 36 | zoomin) 37 | xrandr --output "$current" --scale 0.8x0.8 ;; 38 | zoomout) 39 | xrandr --output "$current" --scale 1.2x1.2 ;; 40 | *) 41 | usage;; 42 | esac 43 | 44 | ## Old code. 45 | # xscreen () { 46 | # ## Does not work? 47 | # cvt $1 $2 48 | # echo "$(cvt $1 $2 | tail -1 | cut -d' ' -f2-)" 49 | # xrandr --newmode "$(cvt $1 $2 | tail -1 | cut -d' ' -f2-)" 50 | # } 51 | -------------------------------------------------------------------------------- /.local/share/applications/mimeapps.list: -------------------------------------------------------------------------------- 1 | /home/ambrevar/.config/mimeapps.list -------------------------------------------------------------------------------- /.mailcap: -------------------------------------------------------------------------------- 1 | image/*; sxiv %s 2 | video/*; mpv %s 3 | */*; xdg-open "%s" 4 | -------------------------------------------------------------------------------- /.mpv/config: -------------------------------------------------------------------------------- 1 | # Write your default config options here! 2 | 3 | # ao=alsa 4 | # profile=opengl-hq 5 | 6 | sub-codepage=utf8 7 | sub-auto=fuzzy 8 | 9 | save-position-on-quit 10 | -------------------------------------------------------------------------------- /.mpv/input.conf: -------------------------------------------------------------------------------- 1 | # Workaround, see https://github.com/mpv-player/mpv/issues/4967. 2 | I show-text "${filename}" -------------------------------------------------------------------------------- /.pkglists/arch-aur: -------------------------------------------------------------------------------- 1 | asmutils 2 | aurutils 3 | clyrics-git 4 | cower 5 | cppcheck-nox 6 | demlo 7 | google-talkplugin 8 | hsync 9 | lostfiles 10 | mygui-gl-git 11 | pacaur 12 | sdlmame-wout-toolkits 13 | tespeed-git 14 | texlive-dummy 15 | translate-shell 16 | -------------------------------------------------------------------------------- /.pkglists/arch-noob: -------------------------------------------------------------------------------- 1 | alsa-plugins 2 | alsa-utils 3 | chromium 4 | cups 5 | epdfview 6 | flashplugin 7 | foomatic-db-nonfree 8 | git 9 | gpicview 10 | gvfs 11 | hplip 12 | ifplugd 13 | iw 14 | libcanberra 15 | libdvdcss 16 | libgphoto2 17 | libreoffice 18 | linux-lts 19 | lxde-icon-theme 20 | lxdm 21 | network-manager-applet 22 | ntfs-3g 23 | python2-gobject2 24 | simple-scan 25 | ttf-dejavu 26 | vlc 27 | wpa_actiond 28 | wpa_supplicant 29 | xfce4 30 | xfce4-goodies 31 | xorg-server 32 | xorg-xinit 33 | xorg-xrdb 34 | -------------------------------------------------------------------------------- /.pkglists/arch-official: -------------------------------------------------------------------------------- 1 | acpi 2 | aircrack-ng 3 | alsa-utils 4 | antiword 5 | asciinema 6 | asp 7 | aspell 8 | aspell-de 9 | aspell-en 10 | aspell-fr 11 | aspell-sv 12 | asymptote 13 | atool 14 | audacity 15 | bash 16 | beets 17 | binutils 18 | bison 19 | blender 20 | bridge-utils 21 | bullet 22 | bzip2 23 | cabextract 24 | cairo 25 | catdoc 26 | catdvi 27 | ccrypt 28 | cdemu-client 29 | cdemu-daemon 30 | cdparanoia 31 | cdrtools 32 | chicken 33 | chmlib 34 | chromaprint 35 | chromium 36 | chrpath 37 | cloc 38 | conky 39 | coreutils 40 | cowsay 41 | cpupower 42 | cronie 43 | cups 44 | curl 45 | cyrus-sasl 46 | darktable 47 | dash 48 | dcadec 49 | dcraw 50 | devtools 51 | dgen-sdl 52 | dhclient 53 | dhcpcd 54 | dialog 55 | diffutils 56 | djvulibre 57 | dmenu 58 | dmidecode 59 | docx2txt 60 | dosbox 61 | dosfstools 62 | driconf 63 | dtach 64 | dvdbackup 65 | dzen2 66 | e2fsprogs 67 | elfutils 68 | emacs 69 | emms 70 | encfs 71 | ethtool 72 | exfat-utils 73 | exiv2 74 | expac 75 | faac 76 | faad2 77 | fakechroot 78 | fakeroot 79 | fbida 80 | fdupes 81 | ffmpeg 82 | ffmpegthumbnailer 83 | file 84 | findutils 85 | fish 86 | flac 87 | flex 88 | foomatic-db 89 | fortune-mod 90 | freeglut 91 | fuse2 92 | fuseiso 93 | gaupol 94 | gawk 95 | gcc 96 | gcc-libs 97 | gcolor2 98 | gdb 99 | gens-gs 100 | gettext 101 | ghostscript 102 | giflib 103 | gifsicle 104 | gimp 105 | git 106 | glew 107 | glfw-x11 108 | glibc 109 | glm 110 | glu 111 | gnupg 112 | go 113 | go-tools 114 | godep 115 | gparted 116 | gptfdisk 117 | graphicsmagick 118 | graphviz 119 | grep 120 | groff 121 | gsl 122 | gst-libav 123 | gst-plugins-base 124 | gst-plugins-base-libs 125 | gst-plugins-good 126 | gtypist 127 | guile1.8 128 | guvcview 129 | gzip 130 | hddtemp 131 | hdparm 132 | hfsprogs 133 | highlight 134 | hplip 135 | htop 136 | hugin 137 | ifplugd 138 | iftop 139 | imagemagick 140 | inetutils 141 | inkscape 142 | inxi 143 | iotop 144 | iproute2 145 | iputils 146 | isync 147 | iw 148 | jfsutils 149 | jhead 150 | jshon 151 | lame 152 | lbzip2 153 | less 154 | libvpx 155 | lilypond 156 | linux 157 | linux-headers 158 | linux-lts 159 | linux-manpages 160 | linuxconsole 161 | lm_sensors 162 | lrzip 163 | lsb-release 164 | lshw 165 | lsof 166 | ltrace 167 | lua 168 | lua-lgi 169 | luajit 170 | lvm2 171 | lxdm 172 | lz4 173 | lzop 174 | make 175 | man-db 176 | man-pages 177 | maxima 178 | mcomix 179 | mcpp 180 | mdadm 181 | mediainfo 182 | mesa 183 | mesa-demos 184 | metapixel 185 | mkvtoolnix-cli 186 | mlocate 187 | mp3info 188 | mpg123 189 | mps-youtube 190 | mpv 191 | mtools 192 | mu 193 | mupen64plus 194 | musl 195 | mutagen 196 | namcap 197 | nasm 198 | nawk 199 | ncdu 200 | net-tools 201 | netctl 202 | nethack 203 | nethogs 204 | nfs-utils 205 | ngrep 206 | nmap 207 | ntfs-3g 208 | numlockx 209 | odt2txt 210 | ogmtools 211 | openal 212 | openbsd-netcat 213 | opengl-man-pages 214 | openscenegraph 215 | openssh 216 | optipng 217 | opus 218 | opus-tools 219 | opusfile 220 | p7zip 221 | pacgraph 222 | pacman 223 | parallel 224 | parted 225 | pass 226 | patch 227 | pciutils 228 | pcmciautils 229 | pcsxr 230 | pdf2djvu 231 | pdf2svg 232 | perl-authen-sasl 233 | perl-crypt-passwdmd5 234 | perl-net-smtp-ssl 235 | pkg-config 236 | pkgbuild-introspection 237 | pkgstats 238 | plan9port 239 | poppler 240 | poppler-glib 241 | procps-ng 242 | psmisc 243 | pstotext 244 | pwgen 245 | python-keyutils 246 | qutebrowser 247 | racket-minimal 248 | rawtherapee 249 | rclone 250 | recode 251 | recordmydesktop 252 | reiserfsprogs 253 | rfkill 254 | rmlint 255 | rsync 256 | sane 257 | scrot 258 | sdl2 259 | sdl2_image 260 | sdparm 261 | sed 262 | slock 263 | splint 264 | squashfs-tools 265 | sshfs 266 | steam 267 | steam-native-runtime 268 | strace 269 | subdl 270 | sudo 271 | sxiv 272 | syslinux 273 | sysstat 274 | sysvbanner 275 | taglib 276 | tar 277 | tcc 278 | tcpdump 279 | testdisk 280 | texi2html 281 | texinfo 282 | the_silver_searcher 283 | time 284 | timidity++ 285 | timidity-freepats 286 | tor 287 | transmission-cli 288 | trash-cli 289 | tre 290 | tree 291 | ttf-dejavu 292 | txt2man 293 | uchardet 294 | ucl 295 | udiskie 296 | unace 297 | unarj 298 | uncrustify 299 | units 300 | unrar 301 | unrtf 302 | unshield 303 | unzip 304 | upx 305 | usb_modeswitch 306 | usbutils 307 | util-linux 308 | v4l-utils 309 | valgrind 310 | vhba-module 311 | vi 312 | vorbis-tools 313 | vsftpd 314 | w3m 315 | wavpack 316 | wayland 317 | wget 318 | which 319 | wildmidi 320 | wine 321 | winetricks 322 | wipe 323 | wireless_tools 324 | wireshark-cli 325 | wireshark-common 326 | wireshark-gtk 327 | wpa_actiond 328 | wpa_supplicant 329 | wv 330 | x264 331 | x265 332 | xcape 333 | xchm 334 | xdg-user-dirs 335 | xdg-utils 336 | xdotool 337 | xf86-video-vesa 338 | xfsprogs 339 | xloadimage 340 | xorg-bdftopcf 341 | xorg-fonts-type1 342 | xorg-server 343 | xorg-server-xephyr 344 | xorg-setxkbmap 345 | xorg-xbacklight 346 | xorg-xdpyinfo 347 | xorg-xev 348 | xorg-xfontsel 349 | xorg-xinit 350 | xorg-xinput 351 | xorg-xkbcomp 352 | xorg-xkill 353 | xorg-xprop 354 | xorg-xrandr 355 | xorg-xrdb 356 | xorg-xset 357 | xosd 358 | xsel 359 | xss-lock 360 | xterm 361 | xz 362 | youtube-dl 363 | zip 364 | -------------------------------------------------------------------------------- /.pkglists/guix: -------------------------------------------------------------------------------- 1 | (specifications->manifest 2 | '( 3 | "acpi" 4 | "aircrack-ng" 5 | "alsa-utils" 6 | "aspell" 7 | "aspell-dict-en" 8 | "aspell-dict-fr" 9 | "atool" 10 | "audacity" 11 | "bluez" 12 | "bzip2" 13 | "chromaprint" 14 | "cloc" 15 | "conkeror" 16 | "conky" 17 | "diffoscope" 18 | "dmidecode" 19 | "dosfstools" 20 | "dtach" 21 | "dzen" 22 | "e2fsprogs" 23 | "electrum" 24 | "emacs" 25 | "emacs-auctex" 26 | "emacs-bash-completion" 27 | "emacs-company" 28 | "emacs-daemons" 29 | "emacs-elfeed" 30 | "emacs-emms" 31 | "emacs-engine-mode" 32 | "emacs-esh-autosuggest" 33 | "emacs-esup" 34 | "emacs-evil" 35 | "emacs-evil-collection" 36 | "emacs-evil-commentary" 37 | "emacs-evil-magit" 38 | "emacs-evil-multiedit" 39 | "emacs-evil-org" 40 | "emacs-expand-region" 41 | "emacs-exwm" 42 | "emacs-fish-completion" 43 | "emacs-flycheck" 44 | "emacs-gif-screencast" 45 | "emacs-google-translate" 46 | "emacs-guix" 47 | "emacs-helm" 48 | "emacs-helm-company" 49 | "emacs-helm-descbinds" 50 | "emacs-helm-emms" 51 | "emacs-helm-eww" 52 | "emacs-helm-exwm" 53 | "emacs-helm-flycheck" 54 | "emacs-helm-ls-git" 55 | "emacs-helm-mu" 56 | "emacs-helm-pass" 57 | "emacs-helm-system-packages" 58 | "emacs-image+" 59 | "emacs-lispyville" 60 | "emacs-lua-mode" 61 | "emacs-markdown-mode" 62 | "emacs-org" 63 | "emacs-org-bullets" 64 | "emacs-org-contrib" 65 | "emacs-package-lint" 66 | "emacs-pdf-tools" 67 | "emacs-pulseaudio-control" 68 | "emacs-rainbow-delimiters" 69 | "emacs-rainbow-mode" 70 | "emacs-slime" 71 | "emacs-strace-mode" 72 | "emacs-sx" 73 | "emacs-transmission" 74 | "emacs-wgrep" 75 | "emacs-wgrep-helm" 76 | "encfs" 77 | "ffmpeg" 78 | "file" 79 | "font-dejavu" 80 | "fortune-mod" 81 | "gawk" 82 | "gcc-toolchain" 83 | "geiser" 84 | "gettext" 85 | "ghostscript" 86 | "gifsicle" 87 | "gimp" 88 | "git" 89 | "git:credential-netrc" 90 | "git:send-email" 91 | "glibc-utf8-locales" 92 | "gnu-standards" 93 | "gnupg" 94 | "go" 95 | "go:doc" 96 | "go:tests" 97 | "graphviz" 98 | "gtypist" 99 | "guile" 100 | "guile-gnome" 101 | "guile-opengl" 102 | "guile-readline" 103 | "guile-sdl" 104 | "guile-sdl2" 105 | "guile:debug" 106 | "htop" 107 | "icecat" 108 | "imagemagick" 109 | "inxi" 110 | "isync" 111 | "libextractor" 112 | "libvorbis" 113 | "light" 114 | "lsof" 115 | "lua" 116 | "magit" 117 | "make" 118 | "man-pages" 119 | "mcron" 120 | "mediainfo" 121 | "mlocate" 122 | "mps-youtube" 123 | "mpv" 124 | "mtools" 125 | "mu" 126 | "nasm" 127 | "nethogs" 128 | "nmap" 129 | "openssh" 130 | "optipng" 131 | "opus-tools" 132 | "p7zip" 133 | "password-store" 134 | "patchelf" 135 | "pavucontrol" 136 | "perl" 137 | "pinentry-emacs" 138 | "pkg-config" 139 | "ploticus" 140 | "poppler" 141 | "powertop" 142 | "pulseaudio" 143 | "pwgen" 144 | "racket" 145 | "recutils" 146 | "rsync" 147 | "scrot" 148 | "setxkbmap" 149 | "sicp" 150 | "speedtest-cli" 151 | "stow" 152 | "strace" 153 | "subdl" 154 | "sxiv" 155 | "taglib" 156 | "tcpdump" 157 | "the-silver-searcher" 158 | "time" 159 | "tor" 160 | "translate-shell" 161 | "transmission" 162 | "trash-cli" 163 | "tree" 164 | "udisks" 165 | "units" 166 | "unrar" 167 | "unrtf" 168 | "unzip" 169 | "upx" 170 | "valgrind" 171 | "vorbis-tools" 172 | "wget" 173 | "wine" 174 | "woof" 175 | "xbacklight" 176 | "xbindkeys" 177 | "xcape" 178 | "xdg-utils" 179 | "xdotool" 180 | "xdpyinfo" 181 | "xev" 182 | "xinit" 183 | "xkbcomp" 184 | "xkill" 185 | "xosd" 186 | "xprop" 187 | "xrandr" 188 | "xrdb" 189 | "xss-lock" 190 | "youtube-dl" 191 | )) 192 | -------------------------------------------------------------------------------- /.pkglists/texlive: -------------------------------------------------------------------------------- 1 | adjustbox 2 | amsmath 3 | babel 4 | caption 5 | collectbox 6 | csquotes 7 | dvipng 8 | ec 9 | etoolbox 10 | eurosym 11 | geometry 12 | graphics 13 | graphics-cfg 14 | graphics-def 15 | hyperref 16 | l3experimental 17 | l3kernel 18 | l3packages 19 | latex 20 | latex-bin 21 | latex-fonts 22 | latexconfig 23 | listings 24 | lm 25 | marvosym 26 | media9 27 | oberdiek 28 | ocgx2 29 | psnfss 30 | symbol 31 | tools 32 | ulem 33 | url 34 | xkeyval 35 | zapfding 36 | -------------------------------------------------------------------------------- /.profile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## This file should be automatically sourced by the login manager or Bash if 3 | ## .bash_profile does not exist. If this file is not automatically sourced, 4 | ## do it from the shell config to me sure it applies to TTY as well. 5 | 6 | ## Mask 7 | ## Result for 027 is "rwxr-x---". 022 is the popular default. 8 | ## 9 | ## As a result applications make the bad assumption # that "others" have access. 10 | ## Another drawback of 027 is that is behaves badly with default sudo config: for 11 | ## instance "sudo mkdir foo" will effectively create a "foo" folder whose owner 12 | ## is root and with permission 027, even if root's umask is 022. This is 13 | ## usually very bad. 14 | ## See https://wiki.archlinux.org/index.php/Sudo#Permissive_umask. 15 | ## 16 | ## It is possible to override sudo's umask by adding the following to the 17 | ## sudoers file: 18 | ## 19 | ## Defaults umask = 0022 20 | ## Defaults umask_override 21 | # umask 027 22 | 23 | 24 | 25 | ## Preliminary path definitions. For security reasons (and bad programming 26 | ## assumptions) you should always append entries to PATH, not prepend them. 27 | appendpath () { 28 | [ $# -eq 2 ] && PATHVAR=$2 || PATHVAR=PATH 29 | [ -d "$1" ] || return 30 | eval echo \$$PATHVAR | grep -q "\(:\|^\)$1\(:\|$\)" && return 31 | eval export $PATHVAR="\$$PATHVAR:$1" 32 | } 33 | prependpath () { 34 | [ $# -eq 2 ] && PATHVAR=$2 || PATHVAR=PATH 35 | [ -d "$1" ] || return 36 | eval echo \$$PATHVAR | grep -q "\(:\|^\)$1\(:\|$\)" && return 37 | eval export $PATHVAR="$1:\$$PATHVAR" 38 | } 39 | 40 | ## Use this to override system executables. 41 | prependpath "${HOME}/personal/hackpool" 42 | 43 | ## TeXlive -- TODO: Remove once guix has packaged it all properly. 44 | TEXDIR="${TEXDIR:-/usr/local/texlive}" 45 | if [ -d "${TEXDIR}" ]; then 46 | TEXYEAR=$(/bin/ls -1r "${TEXDIR}" | grep -m1 "[0-9]\{4\}") 47 | TEXDISTRO=$(uname -m)-$(uname | awk '{print tolower($0)}') 48 | TEXFOLDER="${TEXDIR}/${TEXYEAR}/bin/${TEXDISTRO}" 49 | if [ -d "${TEXFOLDER}" ]; then 50 | appendpath $TEXFOLDER 51 | ## Same for INFOPATH, which should have an empty entry 52 | ## at the end, otherwise Emacs will not use standard locations. 53 | prependpath ${TEXDIR}/${TEXYEAR}/texmf/doc/info INFOPATH 54 | 55 | if [ "$(uname -o)" = "GNU/Linux" ]; then 56 | ## Under GNU/Linux, MANPATH must contain one empty entry for 'man' to 57 | ## lookup the default database. Since BSD uses 'manpath' utility, the 58 | ## MANPATH variable is not needed. 59 | prependpath ${TEXDIR}/${TEXYEAR}/texmf/doc/man MANPATH 60 | fi 61 | fi 62 | unset TEXYEAR 63 | unset TEXDISTRO 64 | unset TEXFOLDER 65 | fi 66 | unset TEXDIR 67 | export BIBINPUTS=~/personal/bibliography 68 | 69 | ## Go 70 | if [ -d "$HOME/go" ]; then 71 | export GOPATH=~/go:~/.go-tools 72 | appendpath "$HOME/.go-tools/bin" 73 | appendpath "$HOME/go/bin" 74 | command -v godoc >/dev/null 2>&1 && godoc -http :6060 -play 2>/dev/null & 75 | fi 76 | 77 | ## Cask 78 | appendpath "$HOME/.cask/bin" 79 | 80 | ## Last PATH entries. 81 | appendpath "/usr/lib/surfraw" 82 | appendpath "${HOME}/personal/games/launchers" 83 | appendpath "${HOME}/.local/bin" 84 | command -v pacman >/dev/null 2>&1 && appendpath "${HOME}/.local/bin/pacman" 85 | 86 | ## mcron: needs to be run after PATH is fully set or else local programs could 87 | ## be missing. 88 | if command -v mcron >/dev/null 2>&1; then 89 | mcron & 90 | fi 91 | 92 | ## Remove less history. 93 | LESSHISTFILE='-' 94 | 95 | ## Manpage. 96 | export MANPAGER="less -s" 97 | export MANWIDTH=80 98 | 99 | ## Time display (with ls command for example). GNU 'ls' only. 100 | export TIME_STYLE=+"|%Y-%m-%d %H:%M:%S|" 101 | 102 | ## SSH-Agent 103 | ## Set SSH to use gpg-agent 104 | unset SSH_AGENT_PID 105 | if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then 106 | export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" 107 | fi 108 | # Set GPG TTY 109 | export GPG_TTY=$(tty) 110 | # Refresh gpg-agent tty in case user switches into an X session 111 | gpg-connect-agent updatestartuptty /bye >/dev/null 112 | 113 | ## Linux specific 114 | if [ "$(uname -o)" = "GNU/Linux" ] ; then 115 | ## Startup error log. 116 | ## dmesg 117 | log_dmesg="$(dmesg | grep -i error)" 118 | [ -n "$log_dmesg" ] && echo "$log_dmesg" > "$HOME/errors-dmesg.log" || rm "$HOME/errors-dmesg.log" 2>/dev/null 119 | ## systemd 120 | if command -v systemctl >/dev/null 2>&1; then 121 | count="$(systemctl show | awk -F= '$1=="NFailedUnits" {print $2; exit}')" 122 | if [ $count -ne 0 ]; then 123 | systemctl -l --failed > "$HOME/errors-systemd.log" 124 | else 125 | rm -f "$HOME/errors-systemd.log" 126 | fi 127 | fi 128 | 129 | ## Set sound volume. (Useless when running Pulseaudio.) 130 | # amixer 2>/dev/null | grep -q PCM && amixer set PCM 100% 131 | 132 | ## External device auto-mounting. 133 | ## If already started, the new process will replace the old one. 134 | if command -v udiskie >/dev/null 2>&1; then 135 | udiskie & 136 | elif command -v devmon >/dev/null 2>&1; then 137 | devmon & 138 | else 139 | udisks-automount & 140 | fi 141 | fi 142 | 143 | ## Wine DLL overrides. 144 | ## Remove the annoying messages for Mono and Gecko. 145 | export WINEDLLOVERRIDES="mscoree,mshtml=" 146 | ## Do not create desktop links or start menu entries. 147 | export WINEDLLOVERRIDES="$WINEDLLOVERRIDES;winemenubuilder.exe=d" 148 | 149 | ## Pacman asp root. 150 | if command -v asp >/dev/null 2>&1; then 151 | export ASPROOT="$HOME/.cache/asp" 152 | fi 153 | 154 | ## Guix 155 | if command -v guix >/dev/null 2>&1; then 156 | export GUIX_PACKAGE_PATH="$HOME/.guix-packages" 157 | fi 158 | 159 | ## Default text editor 160 | ## 'em' is a custom wrapper for emacsclient. See '.bin/em'. 161 | ## VISUAL is given priority by some programs like Mutt. This way we can separate 162 | ## editors that wait from those that don't. 163 | for i in emacsclient em emacs vim vi nano; do 164 | command -v $i >/dev/null 2>&1 && export EDITOR=$i && break 165 | done 166 | GIT_EDITOR="$EDITOR" 167 | VISUAL="$EDITOR" 168 | [ "$GIT_EDITOR" = em ] && GIT_EDITOR=emc 169 | [ "$VISUAL" = em ] && VISUAL=emw 170 | export GIT_EDITOR 171 | export VISUAL 172 | 173 | ## $HOME software install 174 | ## See http://nullprogram.com/blog/2017/06/19/. 175 | ## The variables should not contain paths to non-existing folders as it may 176 | ## break compilers. 177 | prependpath "$HOME/.local/include" C_INCLUDE_PATH 178 | prependpath "$HOME/.local/include" CPLUS_INCLUDE_PATH 179 | prependpath "$HOME/.local/lib" LIBRARY_PATH 180 | prependpath "$HOME/.local/lib/pkgconfig" PKG_CONFIG_PATH 181 | prependpath "$HOME/.local/share/info" INFOPATH 182 | prependpath "$HOME/.local/share/man" MANPATH 183 | ## If you install a library in your home directory that is also installed on the 184 | ## system, and then run a system program, it may be linked against your library 185 | ## rather than the library installed on the system as was originally 186 | ## intended. This could have detrimental effects. 187 | # export LD_LIBRARY_PATH=$HOME/.local/lib 188 | 189 | ## Hook. Should be sourced last 190 | [ -f ~/.profile_hook ] && . ~/.profile_hook 191 | ## Hook example 192 | # 193 | # export CPPFLAGS=-I$HOME/local/usr/include 194 | # export LDFLAGS=-L$HOME/local/usr/lib 195 | # 196 | # appendpath "$HOME/local/usr/lib/python2.7/dist-packages/" PYTHONPATH 197 | # export LUA_CPATH="$HOME/local/usr/lib/lib?.so;$(lua -e "print(package.cpath)")" 198 | # 199 | # umask 077 200 | 201 | ## End: Source .bashrc. The rc file should guard against non-interactive shells. 202 | [ "$(ps -o comm= $$)" != bash ] && return 203 | [ -f ~/.bashrc ] && . ~/.bashrc 204 | 205 | [ -z "$DISPLAY" ] && [ "$(tty)" = '/dev/tty1' ] && exec xinit -- vt01 206 | -------------------------------------------------------------------------------- /.toprc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ambrevar/dotfiles/25e2ed350b898c3fc2df3148630b5778a3db4ee7/.toprc -------------------------------------------------------------------------------- /.uncrustify.cfg: -------------------------------------------------------------------------------- 1 | # Ambrevar C-style 2 | 3 | # Inspired by K&R and Go, with function opening brace on the same line. 4 | # We enforce some sane properties, such as UTF-8 and LF newlines. 5 | # No alignment, tab-indented. 6 | 7 | ################################################################################ 8 | # General options 9 | 10 | newlines = lf 11 | utf8_bom = remove 12 | utf8_byte = true 13 | utf8_force = true 14 | 15 | ################################################################################ 16 | # Indenting 17 | 18 | # 1=indent to level only, 2=indent with tabs 19 | indent_with_tabs = 2 20 | 21 | input_tab_size = 8 22 | indent_columns = output_tab_size 23 | 24 | # How to indent goto labels 25 | # >0 : absolute column where 1 is the leftmost column 26 | # <=0 : subtract from brace indent 27 | indent_label = 0 28 | 29 | # Whether to indent comments found in first column 30 | indent_col1_comment = true # false/true 31 | 32 | # The continuation indent. If non-zero, this overrides the indent of '(' and '=' continuation indents. 33 | # For FreeBSD, this is set to 4. Negative value is absolute and not increased for each ( level 34 | indent_continue = output_tab_size # number 35 | 36 | ################################################################################ 37 | # Code modifying options (non-whitespace) 38 | 39 | mod_paren_on_return = remove # "return 1;" -> "return (1);" 40 | mod_full_brace_if = force # "if (a) a--;" -> "if (a) { a--; }" 41 | mod_full_brace_for = force 42 | mod_full_brace_do = force 43 | mod_full_brace_while = force 44 | 45 | ################################################################################ 46 | # Newline adding and removing options 47 | 48 | nl_enum_brace = remove # "enum \n {" -> "enum {" 49 | nl_union_brace = remove 50 | nl_struct_brace = remove 51 | nl_do_brace = remove 52 | nl_if_brace = remove 53 | nl_for_brace = remove 54 | nl_else_brace = remove 55 | nl_while_brace = remove 56 | nl_switch_brace = remove 57 | nl_fcall_brace = remove 58 | nl_fdef_brace = remove 59 | nl_brace_while = remove 60 | nl_brace_else = remove 61 | 62 | # Whether to not put blanks after '#ifxx', '#elxx', or before '#endif' 63 | # nl_squeeze_ifdef = true 64 | 65 | # Add or remove newline between return type and function name in a function definition 66 | nl_func_type_name = remove 67 | 68 | # Whether to remove blank lines before/after '}'/'{' respectively. 69 | eat_blanks_before_close_brace = true 70 | eat_blanks_after_open_brace = true 71 | 72 | # nl_after_return = true 73 | # nl_func_var_def_blk = 1 74 | # nl_before_case = 1 75 | 76 | ################################################################################ 77 | # Spacing options 78 | 79 | sp_arith = force 80 | sp_assign = force 81 | sp_bool = force 82 | sp_compare = force 83 | sp_before_semi = remove 84 | sp_before_square = remove 85 | sp_before_squares = remove 86 | sp_inside_square = remove 87 | sp_after_comma = force 88 | sp_after_cast = remove # "(int) a" -> "(int)a" 89 | sp_after_sparen = force # "if (){" -> "if () {" 90 | sp_before_sparen = force # "if (" -> "if(" 91 | sp_inside_paren = remove # "( 1 )" -> "(1)" 92 | sp_paren_paren = remove # space between (( and )) 93 | sp_inside_fparen = remove # "( 1 )" -> "(1)" - functions 94 | sp_inside_sparen = remove # "( 1 )" -> "(1)" - if/for/etc 95 | sp_sizeof_paren = force # "sizeof(int)" -> "sizeof (int)" 96 | sp_inside_braces = remove # "{ 1 }" -> "{1}" 97 | sp_inside_braces_struct = remove # "{ 1 }" -> "{1}" 98 | sp_inside_braces_enum = remove # "{ 1 }" -> "{1}" 99 | sp_func_def_paren = remove # "int foo () {" -> "int foo() {" 100 | sp_func_proto_paren = remove # "int foo ();" -> "int foo();" 101 | sp_func_call_paren = remove # "foo (" -> "foo(" 102 | sp_return_paren = remove # "return (1);" -> "return(1);" 103 | sp_else_brace = force # "else{" -> "else {" 104 | sp_brace_else = force # "}else" -> "} else" 105 | 106 | # Add or remove space before pointer star '*' 107 | sp_before_ptr_star = force # ignore/add/remove/force 108 | # Add or remove space between pointer stars '*' 109 | sp_between_ptr_star = remove # ignore/add/remove/force 110 | # Add or remove space after pointer star '*', if followed by a word. 111 | sp_after_ptr_star = remove # ignore/add/remove/force 112 | 113 | # Add or remove space between return type and function name 114 | # A minimum of 1 is forced except for pointer return types. 115 | sp_type_func = force 116 | 117 | # Add or remove space between ')' and '(' of function 118 | sp_fparen_brace = force 119 | 120 | ################################################################################ 121 | # Comment modifications 122 | 123 | # Whether to change cpp-comments into c-comments 124 | cmt_cpp_to_c = true 125 | 126 | # Whether to put a star on subsequent comment lines 127 | # cmt_star_cont = true 128 | 129 | # If false, disable all multi-line comment changes, including cmt_width. keyword substitution, and leading chars. 130 | cmt_indent_multi = false 131 | 132 | # Set the comment reflow mode (default: 0) 133 | # 0: no reflowing (apart from the line wrapping due to cmt_width) 134 | # 1: no touching at all 135 | # 2: full reflow 136 | # cmt_reflow_mode = 0 137 | 138 | ################################################################################ 139 | # Preprocessor options 140 | 141 | # Add or remove space after # based on pp_level of #if blocks 142 | pp_space = remove 143 | 144 | # Whether to indent #if/#else/#endif at the brace level (true) or from column 1 (false) 145 | pp_indent_at_level = true # false/true 146 | # Whether to indent '#define' at the brace level (true) or from column 1 (false) 147 | pp_define_at_level = true # false/true 148 | -------------------------------------------------------------------------------- /.units: -------------------------------------------------------------------------------- 1 | !include ./.cache/currency.units 2 | -------------------------------------------------------------------------------- /.xbindkeysrc: -------------------------------------------------------------------------------- 1 | ## ALSA volume 2 | "amixer set Master 5%-" 3 | XF86AudioLowerVolume 4 | "amixer set Master 5%+" 5 | XF86AudioRaiseVolume 6 | ## Toggling ALSA master also mutes other channels (e.g. speakers) when 7 | ## Pulseaudio is running. 8 | # "amixer set Master toggle" 9 | "pactl set-sink-mute @DEFAULT_SINK@ toggle" 10 | XF86AudioMute 11 | 12 | ## Screen brightness 13 | # "xbacklight -inc 20" 14 | "light -A 20" 15 | XF86MonBrightnessUp 16 | # "xbacklight -dec 20" 17 | "light -U 20" 18 | XF86MonBrightnessDown 19 | -------------------------------------------------------------------------------- /.xinitrc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## WARNING: If started from TTY on a multi-seat, the user must run 'startx & 4 | ## vlock' to ensure the X locker cannot be bypassed. 5 | 6 | ## Run site init scripts. Usually not necessary. 7 | if [ -d /etc/X11/xinit/xinitrc.d ] ; then 8 | for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do 9 | [ -x "$f" ] && . "$f" 10 | done 11 | unset f 12 | fi 13 | 14 | ## Source environment config. 15 | [ -f ~/.xprofile ] && . ~/.xprofile 16 | 17 | ## Launch session 18 | if [ $# -eq 1 ] && command -v $1 >/dev/null 2>&1; then 19 | exec $1 20 | else 21 | conky | dzen2 -p -dock -ta l -fn "DejaVu Sans Mono" & 22 | ## `exwm-enable' has to be called before the frame is spawned. 23 | emacs --daemon -f exwm-enable 24 | exec emacsclient -c 25 | fi 26 | -------------------------------------------------------------------------------- /.xkb/symbols/usim: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // XKB us improved 3 | //------------------------------------------------------------------------------ 4 | // 5 | // Description: This keyboard layout is based on Xorg's "us" and inspired by 6 | // "us(intl)". Caps Lock is Ctrl and LShift+RShift is Caps Lock. For best 7 | // vi-style experience, set the new Ctrl to be Esc when not used as a modifier. 8 | // 9 | // User setup: run 10 | // 11 | // $ xkbcomp -I/path/ $thisfile $DISPLAY` 12 | // 13 | // /path/ must contain a subfolder "symbols" with the "usim" file inside. 14 | // 15 | // System setup: copy the "usim" file to "/usr/{local/,}share/X11/xkb/symbols". You 16 | // can use it by selecting the "usim" layout from Xorg configuration file, or by 17 | // issuing the following command: 18 | // 19 | // $ setxkbmap usim 20 | // 21 | // ┏━━━━━━┓ 22 | // ┃ ┃ 23 | // ┃Esc ┃ 24 | // ┡━━━━━┯┹────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┲━━━━━━━━━┓ 25 | // │ ~ ~ │ ! ¡ │ @ ˝ │ # ¯ │ $ ¤ │ % ¢ │ ^ ^ │ & ¼ │ * ¾ │ ( ˘ │ ) ÷ │ _ × │ + ± ┃ ⌫ Back ┃ 26 | // │ ` ` │ 1 ¹ │ 2 ² │ 3 ³ │ 4 £ │ 5 € │ 6 ¥ │ 7 ½ │ 8 „ │ 9 “ │ 0 ” │ - ⋅ │ = ≠ ┃ space ┃ 27 | // ┢━━━━━┷━┱───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┴─┬───┺━┳━━━━━━━┫ 28 | // ┃ ┃ Q À │ W È │ E É │ R ® │ T ™ │ Y Ù │ U Ú │ I Í │ O Ó │ P Å │ { ‘ │ } ’ ┃ Enter ┃ 29 | // ┃Tab ↹ ┃ q à │ w è │ e é │ r ® │ t © │ y ù │ u ú │ i í │ o ó │ p å │ [ « │ ] » ┃ ⏎ ┃ 30 | // ┣━━━━━━━┻┱────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┴┬────┺┓ ┃ 31 | // ┃ ┃ A Á │ S § │ D  │ F Ê │ G Î │ H Ô │ J Û │ K Œ │ L Æ │ : ° │ " ¨ │ | ¦ ┃ ┃ 32 | // ┃Ctrl ┃ a á │ s ß │ d â │ f ê │ g î │ h ô │ j û │ k œ │ l æ │ ; ° │ ' ´ │ \ ¬ ┃ ┃ 33 | // ┣━━━━━━━┳┹────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┬┴────┲┷━━━━━┻━━━━━━┫ 34 | // ┃ ┃ > ≥ │ Z Ä │ X Ë │ C Ï │ V Ö │ B Ü │ N Ñ │ M Ø │ < Ç │ > µ │ ? ¿ ┃ ┃ 35 | // ┃Shift ⇧┃ < ≤ │ z ä │ x ë │ c ï │ v ö │ b ü │ n ñ │ m ø │ , ç │ . … │ / ¶ ┃Shift ⇧ ┃ 36 | // ┣━━━━━━━╋━━━━━┷━┳━━━┷━━━┱─┴─────┴─────┴─────┴─────┴─────┴───┲━┷━━━━━╈━━━━━┻━┳━━━━━━━┳━━━┛ 37 | // ┃ ┃ ┃ ┃ ␣ Non-breaking space ⍽ ┃ ┃ ┃ ┃ 38 | // ┃Ctrl ┃Meta ┃Alt ┃ ␣ Space ⍽ ┃AltGr ⇮┃Menu ┃Ctrl ┃ 39 | // ┗━━━━━━━┻━━━━━━━┻━━━━━━━┹───────────────────────────────────┺━━━━━━━┻━━━━━━━┻━━━━━━━┛ 40 | 41 | partial alphanumeric_keys xkb_symbols "usim" { 42 | 43 | name[Group1]= "English international with dead keys extended"; 44 | 45 | // Alphanumeric section 46 | key { [ grave, asciitilde, dead_grave, dead_tilde ] }; 47 | key { [ 1, exclam, onesuperior, exclamdown ] }; 48 | key { [ 2, at, twosuperior, dead_doubleacute ] }; 49 | key { [ 3, numbersign, threesuperior, dead_macron ] }; 50 | key { [ 4, dollar, sterling, currency ] }; 51 | key { [ 5, percent, EuroSign, cent ] }; 52 | key { [ 6, asciicircum, yen, dead_circumflex ] }; 53 | key { [ 7, ampersand, onehalf, onequarter ] }; 54 | key { [ 8, asterisk, doublelowquotemark, threequarters ] }; 55 | key { [ 9, parenleft, leftdoublequotemark, dead_breve ] }; 56 | key { [ 0, parenright, rightdoublequotemark, division ] }; 57 | key { [ minus, underscore, 0x10022C5, multiply ] }; 58 | key { [ equal, plus, notequal, plusminus ] }; 59 | 60 | key { [ q, Q, agrave, Agrave ] }; 61 | key { [ w, W, egrave, Egrave ] }; 62 | key { [ e, E, eacute, Eacute ] }; 63 | key { [ r, R, registered, registered ] }; 64 | key { [ t, T, copyright, trademark ] }; 65 | key { [ y, Y, ugrave, Ugrave ] }; 66 | key { [ u, U, uacute, Uacute ] }; 67 | key { [ i, I, iacute, Iacute ] }; 68 | key { [ o, O, oacute, Oacute ] }; 69 | key { [ p, P, aring, Aring ] }; 70 | key { [ bracketleft, braceleft, guillemotleft, leftsinglequotemark ] }; 71 | key { [ bracketright, braceright, guillemotright, rightsinglequotemark ] }; 72 | 73 | key { [ a, A, aacute, Aacute ] }; 74 | key { [ s, S, ssharp, section ] }; 75 | key { [ d, D, acircumflex, Acircumflex ] }; 76 | key { [ f, F, ecircumflex, Ecircumflex ] }; 77 | key { [ g, G, icircumflex, Icircumflex ] }; 78 | key { [ h, H, ocircumflex, Ocircumflex ] }; 79 | key { [ j, J, ucircumflex, Ucircumflex ] }; 80 | key { [ k, K, oe, OE ] }; 81 | key { [ l, L, ae, AE ] }; 82 | key { [ semicolon, colon, degree, dead_abovering ] }; 83 | key { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] }; 84 | 85 | key { [ z, Z, adiaeresis, Adiaeresis ] }; 86 | key { [ x, X, ediaeresis, Ediaeresis ] }; 87 | key { [ c, C, idiaeresis, Idiaeresis ] }; 88 | key { [ v, V, odiaeresis, Odiaeresis ] }; 89 | key { [ b, B, udiaeresis, Udiaeresis ] }; 90 | key { [ n, N, ntilde, Ntilde ] }; 91 | key { [ m, M, oslash, Ooblique ] }; 92 | key { [ comma, less, ccedilla, Ccedilla ] }; 93 | key { [ period, greater, 0x1002026, mu ] }; 94 | key { [ slash, question, paragraph, questiondown ] }; 95 | key { [ backslash, bar, notsign, brokenbar ] }; 96 | 97 | key { [ space, space, nobreakspace, nobreakspace ] }; 98 | key { [ less, greater, lessthanequal, greaterthanequal ] }; 99 | 100 | include "level3(ralt_switch)" 101 | include "ctrl(nocaps)" 102 | include "shift(both_capslock)" 103 | }; 104 | -------------------------------------------------------------------------------- /.xkb/usim.xkb: -------------------------------------------------------------------------------- 1 | xkb_keymap { 2 | xkb_keycodes { include "evdev+aliases(qwerty)" }; 3 | xkb_types { include "complete" }; 4 | xkb_compat { include "complete" }; 5 | xkb_symbols { include "pc+usim+inet(evdev)" }; 6 | 7 | // Geometry is completely optional. 8 | // xkb_geometry { include "pc(pc104)" }; 9 | }; 10 | -------------------------------------------------------------------------------- /.xprofile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## This file is sourced by some DM and should not contain any desktop execution. 3 | 4 | ## Internet browsers that need X to run. 5 | for i in next qutebrowser conkeror chromium icecat firefox google-chrome; do 6 | command -v $i >/dev/null 2>&1 && export BROWSER=$i && break 7 | done 8 | 9 | ## ~/.local/share/applications/mimeapps.list shoud symlink to ~/.config/mimeapps.list. 10 | cat< ~/.config/mimeapps.list 11 | [Added Associations] 12 | image/jpeg=sxiv.desktop 13 | video/H264=mpv.desktop 14 | text/html=$BROWSER.desktop 15 | application/pdf=$BROWSER.desktop 16 | 17 | [Default Applications] 18 | image/jpeg=sxiv.desktop 19 | image/png=sxiv.desktop 20 | text/html=$BROWSER.desktop 21 | application/pdf=zathura.desktop 22 | x-scheme-handler/http=$BROWSER.desktop 23 | x-scheme-handler/https=$BROWSER.desktop 24 | EOF 25 | 26 | ## X resources for xterm. 27 | ## Some DM merge this automatically; we merge it for TTY logins. 28 | [ -f "$HOME/.Xresources" ] && xrdb -merge "$HOME/.Xresources" 29 | 30 | ## Load custom keymap and configure input devices. 31 | ## Some login managers don't like output hence the redirection. 32 | setxkbmap -layout us -variant "" 33 | xkbcomp -I"$HOME/.xkb" "$HOME/.xkb/usim.xkb" $DISPLAY 2>/dev/null 34 | xcape -e 'Control_L=Escape' 35 | numlockx on 36 | xbindkeys 37 | ## Disable the touchpad. There might be better ways to do this. 38 | # xinput disable "SynPS/2 Synaptics TouchPad" 39 | 40 | ## Turn off the bell. 41 | xset -b 42 | 43 | ## Lock screen on sleep. 44 | xss-lock slock & 45 | 46 | ## PulseAudio. It should start automatically. 47 | # start-pulseaudio-x11 & 48 | 49 | ## Hook. Should be sourced last. 50 | [ -f ~/.xprofile_hook ] && . ~/.xprofile_hook 51 | -------------------------------------------------------------------------------- /.xsession: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## .xsession is useful with the "slim" login manager to override the 4 | ## desktop selection with custom commands. 5 | exec sh ~/.xinitrc 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .dotfiles 2 | 3 | ## Overview 4 | 5 | I use of Emacs for almost everything, including my window manager (EXWM). See 6 | my [Emacs pro-tips](http://ambrevar.bitbucket.io/emacs/). 7 | 8 | As such, the more-or-less advanced configurations of my former favourite Unix 9 | programs are gone (Awesome, cmus, fish, fzf, Mutt, newsbeuter, ranger, urxvt, 10 | zathura, zsh). You can search for them before the git commit `README: The Big 11 | Emacs Shift`. 12 | 13 | ## Setup 14 | 15 | For the list of programs I currently use, see the `.pkglists/` folder. 16 | 17 | The `homeinit` script fully bootstraps a user profile with required files, 18 | folders, symlinks applications. 19 | 20 | The `homeclean` script removes trash files, caches and warns if critically 21 | private data is found (e.g. PGP keys). 22 | 23 | The `homesync` script updates the package lists, prints the status of all known 24 | projects and optionally pushes the unmerged changes upstream. 25 | 26 | As for managing a dotfiles repository, there are various approaches. 27 | 28 | 29 | ### Direct versioning 30 | 31 | Git makes it possible to use your home folder as a git repo, thus versioning 32 | all files directly. 33 | 34 | cd 35 | git init 36 | git remote add origin 37 | git fetch 38 | git checkout master 39 | 40 | ### GNU Stow 41 | 42 | [GNU Stow](https://www.gnu.org/software/stow/) lets you symlink a project's 43 | files to an arbitrary folder. 44 | 45 | The simplest setup would be to clone the dotfiles to, say, `~/dotfiles` then run 46 | 47 | cd ~/dotfiles 48 | stow . 49 | 50 | This has several advantages over direct versioning: 51 | 52 | - Subfolders in home are not subject to being included into the dotfiles git 53 | repository. This is especially relevant for projects under a version control 54 | system other than git. 55 | 56 | - No need for a `.gitignore`. 57 | 58 | - Simplified file control (add/remove/etc.). 59 | 60 | - You can fine-tune which program configuration to synchronize on a per-system basis. 61 | 62 | - You can manage several configurations for the same programs. 63 | --------------------------------------------------------------------------------