merge
authorMart Lubbers <mart@martlubbers.net>
Wed, 20 Jul 2016 14:45:32 +0000 (16:45 +0200)
committerMart Lubbers <mart@martlubbers.net>
Wed, 20 Jul 2016 14:45:32 +0000 (16:45 +0200)
26 files changed:
.gitmodules
cal/.config/todoman/todoman.conf [new file with mode: 0644]
cal/.config/vdirsyncer/config
dirs.sh [new file with mode: 0644]
email/.mutt/colors.muttrc
email/.mutt/muttrc
email/.mutt/notmuch-config
email/.mutt/notmuch.muttrc [new file with mode: 0644]
music/.config/mpd/mpd.conf [new file with mode: 0644]
music/.local/bin/ncmpcpp [new file with mode: 0755]
music/.ncmpcpp/bindings [new file with mode: 0644]
music/.ncmpcpp/config [new file with mode: 0644]
music/.ncmpcpp/cover.sh [new file with mode: 0755]
pkgs.sh [new file with mode: 0644]
shell/.bash_profile [new file with mode: 0644]
shell/.bashrc
vim/.vim/bundle/vim-spl.git [new submodule]
vim/.vimrc
x/.Xresources
x/.config/i3/config
x/.config/i3status/config
x/.local/bin/lock.sh [new file with mode: 0755]
x/.local/bin/network [new file with mode: 0755]
x/.local/bin/wifi [new file with mode: 0755]
x/.urxvt/ext/font-size [new file with mode: 0755]
x/.xinitrc

index ff93fba..598ab4d 100644 (file)
@@ -7,3 +7,6 @@
 [submodule "vim/.vim/bundle/vim-praat.git"]
        path = vim/.vim/bundle/vim-praat.git
        url = git@github.com:dopefishh/vim-praat.git
+[submodule "vim/.vim/bundle/vim-spl.git"]
+       path = vim/.vim/bundle/vim-spl.git
+       url = git@github.com:dopefishh/vim-spl.git
diff --git a/cal/.config/todoman/todoman.conf b/cal/.config/todoman/todoman.conf
new file mode 100644 (file)
index 0000000..ee89e59
--- /dev/null
@@ -0,0 +1,2 @@
+[main]
+path = ~/.vdirsyncer/cal/default
index c610395..91265d8 100644 (file)
@@ -10,7 +10,6 @@
 [general]
 # A folder where vdirsyncer can store some metadata about each pair.
 status_path = ~/.vdirsyncer/status/
-password_command = pass show caldav_ygdrassil/mart
 
 # CARDDAV
 [pair contacts]
@@ -29,6 +28,7 @@ type = carddav
 url = https://ygdrassil.martlubbers.net/baikal/card.php/addressbooks/mart/default
 auth = digest
 username = mart
+password.fetch = ["command", "pass", "show", "caldav_ygdrassil/mart"]
 
 # CALDAV
 [pair calendar]
@@ -46,3 +46,4 @@ type = caldav
 url = https://ygdrassil.martlubbers.net/baikal/cal.php/calendars/mart/default
 auth = digest
 username = mart
+password.fetch = ["command", "pass", "show", "caldav_ygdrassil/mart"]
diff --git a/dirs.sh b/dirs.sh
new file mode 100644 (file)
index 0000000..0541a6c
--- /dev/null
+++ b/dirs.sh
@@ -0,0 +1,6 @@
+mkdir -pv ~/.config/{khal,khard,vdirsyncer,todoman}
+mkdir -pv ~/.mutt
+mkdir -pv ~/.gnupg
+mkdir -pv ~/.vim/{autoload,bundle}
+mkdir -pv ~/.{local/bin,config/{i3,i3status}}
+mkdir -pv ~/.{ncmpcpp,config/mpd}
index 14f0a08..f9deffe 100644 (file)
@@ -16,6 +16,7 @@ color hdrdefault cyan default
 color signature cyan default
 color index green default ~p
 color index brightyellow default ~N
+color index brightyellow default ~O
 color index blue default ~T
 color index red default ~D
 color index brightblue default ~F
index e7463cb..2743046 100644 (file)
@@ -11,7 +11,7 @@ set mask="!^\\.[^.]"
 source ~/.mutt/mailboxes
 
 # Receiving, sending and searching
-set sendmail="msmtp -C /home/mart/.mutt/msmtprc"
+set sendmail="msmtp -C /home/mrl/.mutt/msmtprc"
 set send_charset="us-ascii:utf-8"
 macro index,pager $ "<shell-escape>offlineimap -c ~/.mutt/offlineimaprc &<enter><sync-mailbox>" "Force refresh"
 macro attach B "<pipe-entry>firefox \"data:text/html;base64,$(base64 -w 0 <&0)\"<enter>"
@@ -56,7 +56,7 @@ set tilde
 set quote_regexp="^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
 
 # Address book
-set query_command= "khard mutt --search '%s'"
+set query_command= "khard email --search '%s'"
 bind editor <Tab> complete-query
 bind editor ^T    complete
 macro index,pager A \
@@ -66,7 +66,11 @@ macro index,pager A \
 # Colors
 source ~/.mutt/colors.muttrc
 
+# notmuch
+source ~/.mutt/notmuch.muttrc
+
 # Crypto
+set crypt_use_gpgme=yes
 set crypt_autosign
 set crypt_replysign
 set crypt_replysignencrypted=yes
index 051e095..73b20c3 100644 (file)
@@ -11,7 +11,7 @@
 # configured here named ".notmuch".
 #
 [database]
-path=/home/mart/.mutt/mail
+path=/home/mrl/.mutt/mail
 
 # User configuration
 #
diff --git a/email/.mutt/notmuch.muttrc b/email/.mutt/notmuch.muttrc
new file mode 100644 (file)
index 0000000..6b299dc
--- /dev/null
@@ -0,0 +1,19 @@
+macro index <F8> \
+"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+<shell-escape>notmuch-mutt -r --prompt search<enter>\
+<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
+<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
+      "notmuch: search mail"
+
+macro index <F9> \
+"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+<pipe-message>notmuch-mutt -r thread<enter>\
+<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
+<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
+      "notmuch: reconstruct thread"
+
+macro index <F6> \
+"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
+<pipe-message>notmuch-mutt tag -- -inbox<enter>\
+<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
+      "notmuch: remove message from inbox"
diff --git a/music/.config/mpd/mpd.conf b/music/.config/mpd/mpd.conf
new file mode 100644 (file)
index 0000000..5532ffb
--- /dev/null
@@ -0,0 +1,41 @@
+db_file            "~/.config/mpd/database"
+log_file           "~/.config/mpd/log"
+
+# Optional
+music_directory    "/mnt/data/music"
+playlist_directory "~/.config/mpd/playlists"
+pid_file           "~/.config/mpd/pid"
+state_file         "~/.config/mpd/state"
+sticker_file       "~/.config/mpd/sticker.sql"
+
+user                           "mrl"
+group                          "mrl"
+bind_to_address                "any"
+
+auto_update    "yes"
+follow_outside_symlinks        "yes"
+follow_inside_symlinks         "yes"
+
+input {
+        plugin "curl"
+#       proxy "proxy.isp.com:8080"
+#       proxy_user "user"
+#       proxy_password "password"
+}
+
+audio_output {
+       type            "pulse"
+       name            "My Pulse Output"
+#      server          "remote_server"         # optional
+#      sink            "remote_server_sink"    # optional
+}
+
+audio_output {
+       type "fifo"
+       name "Visualizer feed"
+       path "/dev/shm/mpd.fifo"
+       format "44100:16:2"
+}
+
+filesystem_charset             "UTF-8"
+id3v1_encoding                 "UTF-8"
diff --git a/music/.local/bin/ncmpcpp b/music/.local/bin/ncmpcpp
new file mode 100755 (executable)
index 0000000..352eee5
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+/usr/bin/ncmpcpp "$@"
+printf "\e]20;;100x100+1000+1000\a"
diff --git a/music/.ncmpcpp/bindings b/music/.ncmpcpp/bindings
new file mode 100644 (file)
index 0000000..5512564
--- /dev/null
@@ -0,0 +1,22 @@
+def_key "j"
+       scroll_down
+def_key "k"
+       scroll_up
+def_key "J"
+       select_item
+       scroll_down
+def_key "K"
+       select_item
+       scroll_up
+def_key "l"
+       next_column
+def_key "l"
+       slave_screen
+def_key "h"
+       previous_column
+def_key "h"
+       master_screen
+def_key "ctrl-j"
+       page_down
+def_key "ctrl-k"
+       page_up
diff --git a/music/.ncmpcpp/config b/music/.ncmpcpp/config
new file mode 100644 (file)
index 0000000..c252e51
--- /dev/null
@@ -0,0 +1,52 @@
+mpd_music_dir = /mnt/data/music
+
+visualizer_fifo_path = /dev/shm/mpd.fifo
+visualizer_output_name = Visualizer feed
+visualizer_in_stereo = yes
+visualizer_type = spectrum
+visualizer_look = .*
+# ●▮
+
+browser_sort_mode = name
+browser_sort_format = {%A - }{%t}|{%f} {(%l)}
+song_columns_list_format = (6f)[green]{NE} (30)[]{a} (30)[white]{t} (30)[cyan]{b} (7f)[magenta]{l}
+
+execute_on_song_change = "~/.ncmpcpp/cover.sh"
+
+playlist_show_remaining_time = yes
+playlist_shorten_total_times = yes
+playlist_separate_albums = yes
+
+browser_display_mode = columns
+search_engine_display_mode = columns
+playlist_editor_display_mode = columns
+
+autocenter_mode = yes
+centered_cursor = yes
+
+default_place_to_search_in = database
+user_interface = alternative
+
+media_library_primary_tag = album_artist
+cyclic_scrolling = yes
+
+allow_for_physical_item_deletion = no
+
+startup_screen = "playlist"
+startup_slave_screen = "media_library"
+
+locked_screen_width_part = 50
+ask_for_locked_screen_width_part = no
+
+clock_display_seconds = yes
+display_volume_level = yes
+display_bitrate = yes
+display_remaining_time = yes
+
+ignore_leading_the = yes
+media_library_sort_by_mtime = no
+
+enable_window_title = yes
+
+external_editor = vim
+use_console_editor = yes
diff --git a/music/.ncmpcpp/cover.sh b/music/.ncmpcpp/cover.sh
new file mode 100755 (executable)
index 0000000..6d56ac9
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+shopt -s nullglob
+
+file="$(mpc --format /mnt/data/music/%file% current)"
+printf "\e]20;;100x100+1000+1000\a"
+for c in "${file%/*}/cover."*; do
+       printf "\e]20;$c;30x30+1+94:op=keep-aspect\a"
+done
diff --git a/pkgs.sh b/pkgs.sh
new file mode 100644 (file)
index 0000000..66fb78a
--- /dev/null
+++ b/pkgs.sh
@@ -0,0 +1,33 @@
+sudo apt-get install \
+       bash-completion \
+       build-essential \
+       dunst \
+       flashplugin-nonfree \
+       git \
+       gv \
+       i3-wm \
+       i3status \
+       iotop \
+       man-db \
+       mpd \
+       msmtp \
+       mutt  \
+       ncmpcpp \
+       notmuch \
+       notmuch-mutt \
+       offlineimap \
+       pass \
+       pavucontrol \
+       pinentry-qt \
+       psmisc \
+       puddletag \
+       pulseaudio \
+       python3-virtualenv  \
+       stow \
+       suckless-tools \
+       unzip \
+       vim \
+       virtualbox \
+       w3m \
+       x11-xserver-utils  \
+       xinit
diff --git a/shell/.bash_profile b/shell/.bash_profile
new file mode 100644 (file)
index 0000000..c165d61
--- /dev/null
@@ -0,0 +1,2 @@
+[[ -f ~/.bashrc ]] && . ~/.bashrc
+#[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx || true
index f313733..c7b2658 100644 (file)
@@ -6,23 +6,22 @@ export HISTSIZE=NOTHING
 shopt -s histappend
 export PROMPT_COMMAND='history -a'
 
-. /usr/share/bash-completion/bash_completion
-
 export TERMINAL=urxvtc
 export EDITOR=vim
 export TERM=screen
 export BROWSER=firefox
 export PAGER=less
 
-export SUDO_ASKPASS=/usr/bin/ssh-askpass
-export NOTMUCH_CONFIG=/home/mart/.mutt/notmuch-config
+export SUDO_ASKPASS=/usr/lib/ssh/ssh-askpass
+export NOTMUCH_CONFIG=~/.mutt/notmuch-config
 
-export CLEAN_HOME=~/projects/clean
-export PATH=$PATH:$CLEAN_HOME/lib/exe:$CLEAN_HOME/bin:~/.local/bin
+export CLEAN_HOME=/opt/clean
+export PATH=~/.local/bin:$PATH:$CLEAN_HOME/lib/exe:$CLEAN_HOME/bin
 
 alias ls='ls --color=auto'
 alias grep='grep --color=auto'
 alias vi=vim
+alias autoclean='sudo pacman -R $(pacman -Qtdq)'
 
 set_prompt(){
        last_c=$?
diff --git a/vim/.vim/bundle/vim-spl.git b/vim/.vim/bundle/vim-spl.git
new file mode 160000 (submodule)
index 0000000..833ad97
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 833ad97efb2d15c3051e871a5602a77e8d7f6d56
index bf5bb9c..804f1ba 100644 (file)
@@ -9,6 +9,7 @@ autocmd! bufwritepost .Xresources !xrdb -merge %
 " Some general options
 syntax enable
 filetype indent plugin on
+color torte
 set encoding=utf-8
 set history=1000
 set number
@@ -27,7 +28,7 @@ set shiftwidth=4
 set tabstop=4
 
 " List characters to mark trailing whitespace etc
-set listchars=nbsp:¬,tab:▸\ ,eol:↩,extends:»,precedes:«,trail:•
+"set listchars=nbsp:¬,tab:▸\ ,eol:↩,extends:»,precedes:«,trail:•
 set nolist
 
 " Move through long lines as they were short multiple lines
index 46a807d..6496aad 100644 (file)
@@ -34,23 +34,19 @@ URxvt.urgentOnBell: 1
 URxvt.visualBell: 1
 URxvt.loginShell: 1
 URxvt.scrollBar: 0
-URxvt.saveLines: 10000
+URxvt.saveLines: 1000
 URxvt.internalBorder: 1
 URxvt.externalBorder: 1
 URxvt.mouseWheelScrollPage: 0
 URxvt.pastableTabs: 1
 URxvt.cursorBlink: 0
-URxvt.perl-lib: /home/mart/.urxvt/ext
-URxvt.perl-ext-common: font-size
+URxvt.perl-ext-common: font-size,matcher
+URxvt.url-launcher: /usr/bin/xdg-open
+URxvt.keysym.C-Right: perl:matcher:list
 URxvt.keysym.C-Up: perl:font-size:increase
 URxvt.keysym.C-Down: perl:font-size:decrease
 URxvt.keysym.C-Left: perl:font-size:reset
 
-x11-ssh-askpass*font: xft:DejaVu Sans Mono:style=Book:pixelsize=12
-x11-ssh-askpass*borderWidth: 0
-x11-ssh-askpass*minimumCount: 3
-x11-ssh-askpass*maximumCount: 4
-
 gv.watchFile: 1
 gv.saveposFilename: ~/.cache/gv.savepos
 gv.style: gv_widgetless.dat
index 9fd78e6..568190d 100644 (file)
@@ -13,26 +13,27 @@ set $mod Mod4
 set $font DejaVu Sans Mono
 set $fontsize 12
 
-# lock the screen after 10 minutes
-exec xautolock -locker 'echo RELOADAGENT | gpg-connect-agent; i3lock'
-# set a background
-exec ~/.local/bin/bg
-# start steam
-exec steam
-
-# Toggle music playback
+exec display -window root /tmp/bg.png &\
+       dunst &\
+       urxvtd -q -o -f &\
+       mpd &\
+       xrdb -merge ~/.Xresources &\
+       steam &\
+       setxkbmap -layout dvorak,ru -variant ,phonetic_dvorak -option compose:ralt,grp:menu_toggle
+
+# Toggle playback
 bindsym Pause exec mpc toggle
 # Printscreen current window
 bindsym Shift+Print exec ~/.local/bin/scr window
 # Printscreen
 bindsym Print exec ~/.local/bin/scr
-# lock the screen
-bindsym $mod+l exec xautolock -locknow
 # put a password in the clipboard
-bindsym $mod+y exec ~/.local/bin/passmenu
+bindsym $mod+y exec /usr/share/doc/pass/examples/dmenu/passmenu
+bindsym $mod+b exec ~/.local/bin/network
+bindsym $mod+Shift+b exec ~/.local/bin/wifi
 
 # font for window titles.
-font pango:DejaVu Sans Mono 8
+font pango:$font 8
 
 # use Mouse+$mod to drag floating windows to their wanted position
 floating_modifier $mod
@@ -54,10 +55,11 @@ bindsym $mod+n focus up
 bindsym $mod+s focus right
 
 # alternatively, you can use the cursor keys:
-bindsym $mod+Left exec xbacklight -dec 5
-bindsym $mod+Down exec amixer set Master 5- && kill -n 10 `pidof i3status`
-bindsym $mod+Up exec amixer set Master 5+ && kill -n 10 `pidof i3status`
-bindsym $mod+Right exec xbacklight -inc 5
+bindsym XF86MonBrightnessUp exec xbacklight -inc 10
+bindsym XF86MonBrightnessDown exec xbacklight -dec 10
+bindsym XF86AudioMute exec amixer -c 1 set Master toggle
+bindsym XF86AudioLowerVolume exec amixer -c 1 set Master 5%-
+bindsym XF86AudioRaiseVolume exec amixer -c 1 set Master 5%+
 
 # move focused window
 bindsym $mod+Shift+h move left
@@ -140,7 +142,7 @@ bindsym $mod+p mode "resize"
 # Start i3bar to display a workspace bar (plus the system information i3status
 # finds out, if available)
 bar {
-       status_command /home/mart/projects/i3status/i3status
+       status_command i3status
        modifier $mod
        font pango:$font $fontsize
 }
index 3ade2be..d3b3458 100644 (file)
@@ -3,29 +3,26 @@ general {
        interval = 5
 }
 
-order += "cmd helloworld"
+order += "ethernet enp5s0"
 order += "volume master"
 order += "disk /"
-order += "wireless wlp1s0"
-order += "battery 0"
 order += "tztime local"
 
 volume master {
-        format = "♪: %volume"
-        format_muted = "♪: muted (%volume)"
-        device = "default"
-        mixer = "Master"
-        mixer_idx = 0
+       format = "♪: %volume"
+       format_muted = "♪: muted (%volume)"
+       device = "hw:1"
+}
+
+ethernet enp3s0f1 {
+       format_up = "E: %ip"
+       format_down ="E: down"
 }
 
 tztime local {
-       format = "⌚ %Y-%m-%d %H:%M:%S"
+       format = "%Y-%m-%d %H:%M:%S"
 }
 
 disk "/" {
        format = "%free/%total free"
 }
-
-cmd helloworld {
-       cmd = "pkill -0 quodlibet && quodlibet --print-playing || echo -n Stopped"
-}
diff --git a/x/.local/bin/lock.sh b/x/.local/bin/lock.sh
new file mode 100755 (executable)
index 0000000..213f7d3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+echo RELOADAGENT | gpg-connect-agent
+import -window root -resize 25% - | convert \
+               -pointsize 20 \
+               -gravity center \
+               -fill white \
+               -font DejaVu-Sans-Mono \
+               -annotate +0+0 "Type password to unlock" \
+               -resize 400% \
+               - png:- | i3lock -i /dev/stdin
diff --git a/x/.local/bin/network b/x/.local/bin/network
new file mode 100755 (executable)
index 0000000..4cb4f0c
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+netctl list | cut -b 3- | dmenu | ifne xargs -I{}\
+       sudo -A bash -c "netctl switch-to {} && ntpd -qg && hwclock -w"
diff --git a/x/.local/bin/wifi b/x/.local/bin/wifi
new file mode 100755 (executable)
index 0000000..f024272
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+{ 
+       sudo -A iw dev wlp2s0 scan | grep -Po "(?<=SSID: ).*" | sort -u;
+       netctl list | cut -b 3-; 
+} | sort | uniq -d | head -1 | ifne xargs sudo -A netctl switch-to
diff --git a/x/.urxvt/ext/font-size b/x/.urxvt/ext/font-size
new file mode 100755 (executable)
index 0000000..aba0cf4
--- /dev/null
@@ -0,0 +1,434 @@
+#!/usr/bin/env perl
+#
+# On-the-fly adjusting of the font size in urxvt
+#
+# Copyright (c) 2008 David O'Neill
+#               2012 Noah K. Tilton <noahktilton@gmail.com>
+#               2012-2013 Jan Larres <jan@majutsushi.net>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+#
+# URL: https://github.com/majutsushi/urxvt-font-size
+#
+# Based on:
+# https://github.com/dave0/urxvt-font-size
+# https://github.com/noah/urxvt-font
+#
+
+#:META:X_RESOURCE:%.step:interger:font size increase/decrease step
+
+=head1 NAME
+
+font-size - interactive font size setter
+
+=head1 USAGE
+
+Put the font-size script into $HOME/.urxvt/ext/ and add it to the list
+of enabled perl-extensions in ~/.Xresources:
+
+  URxvt.perl-ext-common: ...,font-size
+
+Add some keybindings:
+
+  URxvt.keysym.C-Up:     font-size:increase
+  URxvt.keysym.C-Down:   font-size:decrease
+  URxvt.keysym.C-S-Up:   font-size:incglobal
+  URxvt.keysym.C-S-Down: font-size:decglobal
+
+Note that for urxvt versions older than 9.21 the resources have to look like this:
+
+  URxvt.keysym.C-Up:     perl:font-size:increase
+  URxvt.keysym.C-Down:   perl:font-size:decrease
+  URxvt.keysym.C-S-Up:   perl:font-size:incglobal
+  URxvt.keysym.C-S-Down: perl:font-size:decglobal
+
+Supported functions:
+
+=over 2
+
+=item * increase/decrease:
+
+      increase or decrease the font size of the current terminal.
+
+=item * incglobal/decglobal:
+
+      same as above and also adjust the X server values so all newly
+      started terminals will use the same fontsize.
+
+=item * incsave/decsave:
+
+      same as incglobal/decglobal and also modify the ~/.Xresources
+      file so the changed font sizes will persist over a restart of
+      the X server or a reboot.
+
+=back
+
+You can also change the step size that the script will use to increase
+the font size:
+
+  URxvt.font-size.step: 4
+
+The default step size is 1. This means that with this setting a
+size change sequence would be for example 8->12->16->20 instead of
+8->9->10->11->12 etc. Please note that many X11 fonts are only
+available in specific sizes, though, and odd sizes are often not
+available, resulting in an effective step size of 2 instead of 1
+in that case.
+=cut
+
+use strict;
+use warnings;
+
+my %escapecodes = (
+    "font"           => 710,
+    "boldFont"       => 711,
+    "italicFont"     => 712,
+    "boldItalicFont" => 713
+);
+
+sub on_start
+{
+    my ($self) = @_;
+
+    $self->{step} = $self->x_resource("%.step") || 1;
+
+    foreach my $type (qw(font boldFont italicFont boldItalicFont)) {
+        $self->{$type} = $self->x_resource($type) || "undef";
+    }
+}
+
+# Needed for backwards compatibility with < 9.21
+sub on_user_command
+{
+    my ($self, $cmd) = @_;
+
+    my $step = $self->{step};
+
+    if ($cmd eq "font-size:increase") {
+        fonts_change_size($self,  $step, 0);
+    } elsif ($cmd eq "font-size:decrease") {
+        fonts_change_size($self, -$step, 0);
+    } elsif ($cmd eq "font-size:incglobal") {
+        fonts_change_size($self,  $step, 1);
+    } elsif ($cmd eq "font-size:decglobal") {
+        fonts_change_size($self, -$step, 1);
+    } elsif ($cmd eq "font-size:incsave") {
+        fonts_change_size($self,  $step, 2);
+    } elsif ($cmd eq "font-size:decsave") {
+        fonts_change_size($self, -$step, 2);
+    } elsif ($cmd eq "font-size:reset") {
+        fonts_reset($self);
+    }
+}
+
+sub on_action
+{
+    my ($self, $action) = @_;
+
+    my $step = $self->{step};
+
+    if ($action eq "increase") {
+        fonts_change_size($self,  $step, 0);
+    } elsif ($action eq "decrease") {
+        fonts_change_size($self, -$step, 0);
+    } elsif ($action eq "incglobal") {
+        fonts_change_size($self,  $step, 1);
+    } elsif ($action eq "decglobal") {
+        fonts_change_size($self, -$step, 1);
+    } elsif ($action eq "incsave") {
+        fonts_change_size($self,  $step, 2);
+    } elsif ($action eq "decsave") {
+        fonts_change_size($self, -$step, 2);
+    } elsif ($action eq "reset") {
+        fonts_reset($self);
+    }
+}
+
+sub fonts_change_size
+{
+    my ($term, $change, $save) = @_;
+
+    my @newfonts = ();
+
+    my $curres = $term->resource('font');
+    if (!$curres) {
+        $term->scr_add_lines("\r\nWarning: No font configured, trying a default.\r\nPlease set a font with the 'URxvt.font' resource.");
+        $curres = "fixed";
+    }
+    my @curfonts = split(/\s*,\s*/, $curres);
+
+    my $basefont = shift(@curfonts);
+    my ($newbasefont, $newbasesize) = handle_font($term, $basefont, $change, 0);
+    push @newfonts, $newbasefont;
+
+    # Only adjust other fonts if base font changed
+    if ($newbasefont ne $basefont) {
+        foreach my $font (@curfonts) {
+            my ($newfont, $newsize) = handle_font($term, $font, $change, $newbasesize);
+            push @newfonts, $newfont;
+        }
+        my $newres = join(",", @newfonts);
+        font_apply_new($term, $newres, "font", $save);
+
+        handle_type($term, "boldFont",       $change, $newbasesize, $save);
+        handle_type($term, "italicFont",     $change, $newbasesize, $save);
+        handle_type($term, "boldItalicFont", $change, $newbasesize, $save);
+    }
+
+    if ($save > 1) {
+        # write the new values back to the file
+        my $xresources = readlink $ENV{"HOME"} . "/.Xresources";
+        system("xrdb -edit " . $xresources);
+    }
+}
+
+sub fonts_reset
+{
+    my ($term) = @_;
+
+    foreach my $type (qw(font boldFont italicFont boldItalicFont)) {
+        my $initial = $term->{$type};
+        if ($initial ne "undef") {
+            font_apply_new($term, $initial, $type, 0);
+        }
+    }
+}
+
+sub handle_type
+{
+    my ($term, $type, $change, $basesize, $save) = @_;
+
+    my $curres = $term->resource($type);
+    if (!$curres) {
+        return;
+    }
+    my @curfonts = split(/\s*,\s*/, $curres);
+    my @newfonts = ();
+
+    foreach my $font (@curfonts) {
+        my ($newfont, $newsize) = handle_font($term, $font, $change, $basesize);
+        push @newfonts, $newfont;
+    }
+
+    my $newres = join(",", @newfonts);
+    font_apply_new($term, $newres, $type, $save);
+}
+
+sub handle_font
+{
+    my ($term, $font, $change, $basesize) = @_;
+
+    my $newfont;
+    my $newsize;
+    my $prefix = 0;
+
+    if ($font =~ /^\s*x:/) {
+        $font =~ s/^\s*x://;
+        $prefix = 1;
+    }
+    if ($font =~ /^\s*(\[.*\])?xft:/) {
+        ($newfont, $newsize) = font_change_size_xft($term, $font, $change, $basesize);
+    } elsif ($font =~ /^\s*-/) {
+        ($newfont, $newsize) = font_change_size_xlfd($term, $font, $change, $basesize);
+    } else {
+        # check whether the font is a valid alias and if yes resolve it to the
+        # actual font
+        my $lsfinfo = `xlsfonts -l $font 2>/dev/null`;
+
+        if ($lsfinfo eq "") {
+            # not a valid alias, ring the bell if it is the base font and just
+            # return the current font
+            if ($basesize == 0) {
+                $term->scr_bell;
+            }
+            return ($font, $basesize);
+        }
+
+        my $fontinfo = (split(/\n/, $lsfinfo))[-1];
+        my ($fontfull) = ($fontinfo =~ /\s+([-a-z0-9]+$)/);
+        ($newfont, $newsize) = font_change_size_xlfd($term, $fontfull, $change, $basesize);
+    }
+
+    # $term->scr_add_lines("\r\nNew font is $newfont\n");
+    if ($prefix) {
+        $newfont = "x:$newfont";
+    }
+    return ($newfont, $newsize);
+}
+
+sub font_change_size_xft
+{
+    my ($term, $fontstring, $change, $basesize) = @_;
+
+    my @pieces   = split(/:/, $fontstring);
+    my @resized  = ();
+    my $size     = 0;
+    my $new_size = 0;
+
+    foreach my $piece (@pieces) {
+        if ($piece =~ /^(?:(?:pixel)?size=|[^=-]+-)(\d+(\.\d*)?)$/) {
+            $size = $1;
+
+            if ($basesize != 0) {
+                $new_size = $basesize;
+            } else {
+                $new_size = $size + $change
+            }
+
+            $piece =~ s/(=|-)$size/$1$new_size/;
+        }
+        push @resized, $piece;
+    }
+
+    my $resized_str = join(":", @resized);
+
+    # don't make fonts too small
+    if ($new_size >= 6) {
+        return ($resized_str, $new_size);
+    } else {
+        if ($basesize == 0) {
+            $term->scr_bell;
+        }
+        return ($fontstring, $size);
+    }
+}
+
+sub font_change_size_xlfd
+{
+    my ($term, $fontstring, $change, $basesize) = @_;
+
+    #-xos4-terminus-medium-r-normal-*-12-*-*-*-*-*-*-1
+
+    my @fields = qw(foundry family weight slant setwidth style pixelSize pointSize Xresolution Yresolution spacing averageWidth registry encoding);
+
+    my %font;
+    $fontstring =~ s/^-//;  # Strip leading - before split
+    @font{@fields} = split(/-/, $fontstring);
+
+    if ($font{pixelSize} eq '*') {
+        $term->scr_add_lines("\r\nWarning: Font size undefined, assuming 12.\r\nPlease set the 'URxvt.font' resource to a font with a concrete size.");
+        $font{pixelSize} = '12'
+    }
+    if ($font{registry} eq '*') {
+        $font{registry} ='iso8859';
+    }
+
+    # Blank out the size for the pattern
+    my %pattern = %font;
+    $pattern{foundry} = '*';
+    $pattern{setwidth} = '*';
+    $pattern{pixelSize} = '*';
+    $pattern{pointSize} = '*';
+    # if ($basesize != 0) {
+    #     $pattern{Xresolution} = '*';
+    #     $pattern{Yresolution} = '*';
+    # }
+    $pattern{averageWidth} = '*';
+    # make sure there are no empty fields
+    foreach my $field (@fields) {
+        $pattern{$field} = '*' unless defined($pattern{$field});
+    }
+    my $new_fontstring = '-' . join('-', @pattern{@fields});
+
+    my @possible;
+    # $term->scr_add_lines("\r\nPattern is $new_fontstring\n");
+    open(FOO, "xlsfonts -fn '$new_fontstring' | sort -u |") or die $!;
+    while (<FOO>) {
+        chomp;
+        s/^-//;  # Strip leading '-' before split
+        my @fontdata = split(/-/, $_);
+
+        push @possible, [$fontdata[6], "-$_"];
+        # $term->scr_add_lines("\r\npossibly $fontdata[6] $_\n");
+    }
+    close(FOO);
+
+    if (!@possible) {
+        die "No possible fonts!";
+    }
+
+    if ($basesize != 0) {
+        # sort by font size, descending
+        @possible = sort {$b->[0] <=> $a->[0]} @possible;
+
+        # font is not the base font, so find the largest font that is at most
+        # as large as the base font. If the largest possible font is smaller
+        # than the base font bail and hope that a 0-size font can be found at
+        # the end of the function
+        if ($possible[0]->[0] > $basesize) {
+            foreach my $candidate (@possible) {
+                if ($candidate->[0] <= $basesize) {
+                    return ($candidate->[1], $candidate->[0]);
+                }
+            }
+        }
+    } elsif ($change > 0) {
+        # sort by font size, ascending
+        @possible = sort {$a->[0] <=> $b->[0]} @possible;
+
+        foreach my $candidate (@possible) {
+            if ($candidate->[0] >= $font{pixelSize} + $change) {
+                return ($candidate->[1], $candidate->[0]);
+            }
+        }
+    } elsif ($change < 0) {
+        # sort by font size, descending
+        @possible = sort {$b->[0] <=> $a->[0]} @possible;
+
+        foreach my $candidate (@possible) {
+            if ($candidate->[0] <= $font{pixelSize} + $change && $candidate->[0] != 0) {
+                return ($candidate->[1], $candidate->[0]);
+            }
+        }
+    }
+
+    # no fitting font available, check whether a 0-size font can be used to
+    # fit the size of the base font
+    @possible = sort {$a->[0] <=> $b->[0]} @possible;
+    if ($basesize != 0 && $possible[0]->[0] == 0) {
+        return ($possible[0]->[1], $basesize);
+    } else {
+        # if there is absolutely no smaller/larger font that can be used
+        # return the current one, and beep if this is the base font
+        if ($basesize == 0) {
+            $term->scr_bell;
+        }
+        return ("-$fontstring", $font{pixelSize});
+    }
+}
+
+sub font_apply_new
+{
+    my ($term, $newfont, $type, $save) = @_;
+
+    # $term->scr_add_lines("\r\nnew font is $newfont\n");
+
+    $term->cmd_parse("\033]" . $escapecodes{$type} . ";" . $newfont . "\033\\");
+
+    # load the xrdb db
+    # system("xrdb -load " . X_RESOURCES);
+
+    if ($save > 0) {
+        # merge the new values
+        open(XRDB_MERGE, "| xrdb -merge") || die "can't fork: $!";
+        local $SIG{PIPE} = sub { die "xrdb pipe broken" };
+        print XRDB_MERGE "URxvt." . $type . ": " . $newfont;
+        close(XRDB_MERGE) || die "bad xrdb: $! $?";
+    }
+}
index 6c2f666..08f1db1 100644 (file)
@@ -1,5 +1,4 @@
-xrdb -merge ~/.Xresources
-urxvtd -q -o -f
+fbgrab /tmp/bg.png
 
 envfile="$HOME/.gnupg/gpg-agent.env"
 if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null
@@ -11,5 +10,4 @@ fi
 export GPG_AGENT_INFO
 export SSH_AUTH_SOCK
 
-setxkbmap -layout dvorak,ru -variant ,phonetic_dvorak -option compose:ralt,grp:menu_toggle
 exec i3