monochromatic

monochromatic blog: http://blog.z3bra.org
git clone git://z3bra.org/monochromatic
Log | Files | Refs

commit 41e38839b23d8ccea33dd48b439143889effbef9
parent 08fbf73988524ea560bf3f0878c6045301744592
Author: z3bra <willyatmailoodotorg>
Date:   Sun, 16 Aug 2015 19:08:52 +0200

Merge branch 'master' of z3bra.org:monochromatic

Diffstat:
2015/01/you-are-the-wm.txt | 191++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2015/04/the-wrong-sysadmin.txt | 170+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2015/06/vomiting-colors.txt | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
config.mk | 4+++-
index.txt | 2++
5 files changed, 442 insertions(+), 2 deletions(-)

diff --git a/2015/01/you-are-the-wm.txt b/2015/01/you-are-the-wm.txt @@ -83,4 +83,193 @@ some nice scripts in there ! Now throw your window manager away, you don't need it anymore. **YOU ARE THE WM !** -<!-- vim: set ft=markdown ts=4 et tw=80: --> +**EDIT** +-------- + +I was asked on reddit to explain my wmutils setup. I gave a fairly +detailed answer which might also be useful for others, so I figured out I could +add it here (original comment [here](https://www.reddit.com/r/unixporn/comments/3b42zj/people_using_wmutils_how_do_you_use_it/csj8iq4)) + +I Have both `wmutils/core` and `wmutils/opt` installed. I need the latter for +`wew`, an X event watcher. + +MANAGING WINDOWS +---------------- + +The central piece of my workflow is `sxhkd`. This is a software one can use to +bind key combos to commands, or **scripts**. I use it both to start my +applications, but also to manage my windows via `wmutils` tools, and scripts. +For instance, here is the entry that let me move windows around the screen using +the keyboard (`pfw` returns the ID of the currently focused window. It's a +rather important piece of software!): + + # move windows around + super + {left,down,up,right} + wmv {-20 0, 0 20, 0 -20, 20, 0} $(pfw) + + # resize windows + super + alt + {left,down,up,right} + wrs {-20 0, 0 20, 0 -20, 20, 0} $(pfw) + +That's for tools that can be bound "directly" via sxhkd. For more complex tasks, +I use a few scripts of my own: + ++ `vroum` - manage window focus ++ `groaw` - manage window groups ++ `focus` - finer way to focus windows ++ `corner` - move windows to screen's corner ++ `fullscreen` - put a window in fullscreen mode + +### vroum + +It can take 3 arguments: "next, prev, $wid". "next" will focus the next +window on the stack, previous will focus the previously focused window, and +every argument starting by `0x` will be considered a window ID to be focused +directly. It will also change the border of all the inactive windows, and the +active window. I use this script to cycle between them: + + # cycle through windows + alt {, + shift} + tab + vroum {next, prev} + +### groaw + +This is my "group" manager (think of it as workspaces on steroid). By +default, new windows are not assigned any groups. Without much explaning how +each flag works, I just need it to perform 3 tasks: + +1. add the current window to a specific group +2. toggle visibility state of a specific group +3. remove current window from all groups + +This result in the following entries: + + # add window to a group + super + shift + {1,2,3,4,5} + groaw -d all; \ + groaw -a {1,2,3,4,5} + + # toggle groups' visibility + super + {1,2,3,4,5} + groaw -t {1,2,3,4,5} + + # remove window from all groups + super + Backspace + groaw -d all + +### focus + +A script I'm really proud of! It focus windows besed on their cardinal +positions. It takes exactly 4 different arguments: + + north + ^ + | + west <---+---> east + | + v + south + +It will then focus the nearest window in the given direction (using top/left +edge of the window) It's bound like so + + # select windows using directions + alt + {left,down,up,right} + focus {west, south, north, east} $(pfw) + +### corner + +There's nothing special about it. It put the window in the corner passed as +argument (Top-Left, Top-Right, Bottom-Left, Bottom-Right, MiDdle) + + # move windows to corners + super + {y,u,b,n,g} + corner {tl, tr, bl, br, md} $(pfw) + +### fullscreen + +Set a window in fullscreen mode (change its size to the size of the monitor, and +remove borders. The previous position/size of the window is saved to a file, so +when you disable fullscreen mode, or move another window in fullscreen, the +window takes its old position back + + # set window fullscreen + super + x + fullscreen $(pfw) + +DEALING WITH EVENTS +------------------- + +The above only applies to existing windows. But when a new window gets created, +I need to run a few commands against it, to integrate it to my workflow. This is +what `wew` is for. It prints X events to stdout, and the window ID the event +applies to. For example: + + 16:0x000c00ea + 19:0x000c00ea + +Event number 16 is "window creation", 19 is "mapping request". I have a parser +script that will perform different actions depending on the fired event (it's +called `yawee`, I like weird names): + + + #!/bin/sh + + while IFS=: read ev wid; do + case $ev in + # window creation: center window on the screen (except docks, menus or similar) + 16) wattr o $wid || corner md $wid ;; + + # mapping requests: just set a special border for docks, menus and + # similar. Focus other windows + 19) wattr o $wid \ + && chwb -s 2 -c 0x323232 $wid \ + || vroum $wid ;; + + # when a window gets deleted, focus another one + 18) wattr $(pfw) || vroum prev 2>/dev/null;; + + # Focus windows when the mouse cursor enter them + 7) wattr o $wid || vroum $wid ;; + esac + done + +In my `$HOME/.xinitrc`, it's started as: + + wew | yawee & + +Pretty straighforward :) + +USING THE MOUSE +--------------- + +Nobody's perfect. I use the mouse from time to time to manage my windows. It is +sometimes more efficient to get a window out of your way quickly, or resize one +approximatively. + +For this purpose, I STILL use sxhkd! Baskerville did an amazing job with this +software, as it support integer replacement of the mouse coordinate + + # move windows with the mouse: + super + !button{1,3} + {wmv, wrs} -a %i %i $(pfw) + +As simple as that! + +MISCELLANOUS +------------ + +For eye candy purpose, I wrote a `pulsar` script, to make my currently active +window standout. It make the window's border "pulse" like in the following +video: http://raw.z3bra.org/dev/random/wall-border.webm. It uses a `$HOME/.colors` +file containing the colors to be used for the gradient. It will then run `chwb` +at a regular interval to change the current window's borders. + + +That's pretty much it! If you have any question, do not hesitate to ask. +Also, sorry for the huge wall of text, I was trying to be as precise as +possible. + +As a bonus, to congratulate you from reading it all, here is a video from my +actual workflow with this setup (writing my latest blogpost: +[(grab some popcorns, it's 57 minutes long)](http://raw.z3bra.org/dev/random/monochromatic-0x0017-writeup.webm) diff --git a/2015/04/the-wrong-sysadmin.txt b/2015/04/the-wrong-sysadmin.txt @@ -0,0 +1,170 @@ +# [The wrong sysadmin](#) +## &mdash; 28 April, 2015 + +*NOTE: This was replicated from the [Unix +Diary](http://nixers.net/showthread.php?tid=1539&pid=11836#pid11836) thread at +[http://nixers.net](http://nixers.net)* + +Dear Unix diary, + +today I've been a bad sysadmin. +It just happened. I host my own git repository, and earlier this evening I was working on my crux port tree, when I decided to commit and push my work. But this time, something went wrong and git didn't let me push any reference. Amongst all the messages returned by git, I saw this one: + + remote: fatal: write error: No space left on device + +Fucking shit. I instantly imagine what's happening: my /var partition wasn't correctly sized upon creation. This is where I host my website, gopherhole, git repo, pictures, videos, ... Every 'production' service. And after serving me well for several years, it's now full. + +Hopefully, I had setup all my partitions on top of LVM, and let like 200GiB available, just in case things go wrong. And they did. + +So here am I, staring at my red prompt, typing a few commands: + + root ~# df -h + Filesystem Size Used Available Use% Mounted on + mdev 1.0M 0 1.0M 0% /dev + shm 499.4M 0 499.4M 0% /dev/shm + /dev/dm-1 4.0G 797.9M 3.2G 20% / + tmpfs 99.9M 208.0K 99.7M 0% /run + cgroup_root 10.0M 0 10.0M 0% /sys/fs/cgroup + /dev/sda1 96.8M 14.5M 77.3M 16% /boot + /dev/mapper/vg0-var 50.0G 50.0G 20.0K 100% /var + /dev/mapper/vg0-home 100.0G 12.9G 85.2G 13% /home + /dev/mapper/vg0-data 600.0G 346.7G 252.1G 58% /data + tmpfs 499.4M 0 499.4M 0% /tmp + tmpfs 499.4M 32.4M 467.0M 6% /home/z3bra/tmp + /dev/mapper/vg0-data 600.0G 346.7G 252.1G 58% /var/lib/mpd/music + + root ~# mount | grep /var + /dev/mapper/vg0-var on /var type xfs (rw,relatime,attr2,inode64,noquota) + + root ~# lvs + LV VG Attr LSize + data vg0 -wi-ao---- 600.00g + home vg0 -wi-ao---- 100.00g + root vg0 -wi-ao---- 4.00g + swap vg0 -wi-ao---- 1.00g + var vg0 -wi-ao---- 50.00g + + root ~# vgs + VG #PV #LV #SN Attr VSize VFree + vg0 1 5 0 wz--n- 931.41g 176.41g + +Ok, so it's not the first time this happens, remember? You already grew your /home partition, and it went good! Just do the same with /var! It works without a reboot! + +What was those commands again? + + root ~# lvextend -L +20G vg0/var + Extending logical volume var to 70.00 GiB + 63e74d07f000-63e74d2c1000 r-xp 00000000 fd:01 8430401 /lib/libdevmapper.so.1.02: mlock failed: Out of memory + 63e74d2c6000-63e74d4cb000 r-xp 00000000 fd:01 8430404 /lib/libdevmapper-event.so.1.02: mlock failed: Out of memory + Logical volume var successfully resized + Internal error: Reserved memory (9064448) not enough: used 9084928. Increase activation/reserved_memory? + + root ~# lvs + LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert + data vg0 -wi-ao---- 600.00g + home vg0 -wi-ao---- 100.00g + root vg0 -wi-ao---- 4.00g + swap vg0 -wi-ao---- 1.00g + var vg0 -wi-ao---- 70.00g + + root ~# xfs_growfs -d /var + meta-data=/dev/mapper/vg0-var isize=256 agcount=4, agsize=3276800 blks + = sectsz=4096 attr=2, projid32bit=1 + = crc=0 + data = bsize=4096 blocks=13107200, imaxpct=25 + = sunit=0 swidth=0 blks + naming =version 2 bsize=4096 ascii-ci=0 ftype=0 + log =internal bsize=4096 blocks=6400, version=2 + = sectsz=4096 sunit=1 blks, lazy-count=1 + realtime =none extsz=4096 blocks=0, rtextents=0 + data blocks changed from 13107200 to 18350080 + + root ~# df -h + Filesystem Size Used Available Use% Mounted on + mdev 1.0M 0 1.0M 0% /dev + shm 499.4M 0 499.4M 0% /dev/shm + /dev/dm-1 4.0G 797.9M 3.2G 20% / + tmpfs 99.9M 208.0K 99.7M 0% /run + cgroup_root 10.0M 0 10.0M 0% /sys/fs/cgroup + /dev/sda1 96.8M 14.5M 77.3M 16% /boot + /dev/mapper/vg0-var 70.0G 50.0G 20.0G 71% /var + /dev/mapper/vg0-home 100.0G 12.9G 85.2G 13% /home + /dev/mapper/vg0-data 600.0G 346.7G 252.1G 58% /data + tmpfs 499.4M 0 499.4M 0% /tmp + tmpfs 499.4M 32.4M 467.0M 6% /home/z3bra/tmp + /dev/mapper/vg0-data 600.0G 346.7G 252.1G 58% /var/lib/mpd/music + +Phew... I'm safe now! So what the hell was going on? I decided to investigate a bit further, to see what I should watch next time. +That's how I realised that I did a **HUGE** mistake... + + root ~# cd /var/ + root var# du -sh * + 48.5G backup + 156.7M cache + 0 db + 0 empty + 228.8M git + 5.7M gopher + 4.5G lib + 0 local + 0 lock + 7.9M log + 0 mail + 0 run + 40.0K spool + 0 tmp + 1.1G www + + root var# cd backup/ + + root backup# du -sh * + 12.0K bin + 20.0K etc + 48.5G out + 20.0K usr + 84.0K var + + root backup# mountpoint out + out is not a mountpoint + + root backup# cd out/ + + root out# ll + total 50841516 + drwxr-sr-x 2 backup users 4.0K Apr 28 02:11 ./ + drwxr-sr-x 8 backup users 4.0K Feb 2 20:24 ../ + -rw-r--r-- 1 backup users 5.3G Apr 25 07:43 data + -rw-r--r-- 1 backup users 0 Apr 25 07:43 data.0.BAK + -rw-r--r-- 1 backup users 12.0G Apr 26 04:37 homedir + -rw-r--r-- 1 backup users 12.0G Apr 22 04:43 homedir.0.BAK + -rw-r--r-- 1 backup users 12.0G Apr 25 05:00 homedir.1.BAK + -rw-r--r-- 1 backup users 44.0K Apr 26 04:42 homedir.2.BAK + -rw-r--r-- 1 backup users 1.2G Apr 28 02:11 production + -rw-r--r-- 1 backup users 1.2G Apr 21 02:10 production.0.BAK + -rw-r--r-- 1 backup users 1.2G Apr 22 02:11 production.1.BAK + -rw-r--r-- 1 backup users 1.2G Apr 23 02:11 production.2.BAK + -rw-r--r-- 1 backup users 1.2G Apr 24 02:11 production.3.BAK + -rw-r--r-- 1 backup users 1.2G Apr 25 02:12 production.4.BAK + -rw-r--r-- 1 backup users 0 Apr 26 02:11 production.5.BAK + -rw-r--r-- 1 backup users 5.3M Apr 27 02:12 production.6.BAK + -rw-r--r-- 1 backup users 0 Apr 28 02:11 production.7.BAK + +My backup system doesn't check wether it saves to a mountpoint or not. Shit. +For a whole week, all my backups where created in my /var partition instead of a backup USB drive meant for this purpose. And it filled it up pretty quickly. + +My backup system send me a mail after each backup, explaining me how it went. The fact it's saving to a mountpoint or not is written in it. I just stopped checking. Silly me. + +I realise that this issue could have been easily solved by mounting my backup disk elsewhere, then moving the files, and remounting where it should be. But I didn't. Instead, I grew a partition that didn't need to be (the backups filled 48GiB out of 50Gib allocated to /var), and this partition can't be shrinked anymore, as it's an XFS filesystem. + +So today I learnt two things, the hard way: + +1. Don't do anything until you know what's going on +2. Configure systems checks and READ THEM + +I hope you'll learn from my mistakes. For now I think I'll just print this over my desktop, as a reminder: + + root ~# df -h /var/ + Filesystem Size Used Available Use% Mounted on + /dev/mapper/vg0-var 70.0G 1.5G 68.5G 2% /var + +<!-- vim: set ft=markdown ts=4 et tw=80: --> diff --git a/2015/06/vomiting-colors.txt b/2015/06/vomiting-colors.txt @@ -0,0 +1,77 @@ +# [Vomiting colors](#) +## &mdash; 09 June, 2015 + +Creating colorschemes is one of the hardest part of customizing your desktop. +The easiest way to create a new one is to start from a wallpaper made of colors +you like, and then rework it afterward. + +the best tool for this job is without any doubt +[colors](http://git.2f30.org/colors) by sin. It uses [k-means +clustering](https://en.wikipedia.org/wiki/K-means_clustering) to extract +dominant colors from a PNG file, and is able to set those clusters in different +ways. + +Without any further commenting, let's see how it works with this magnificent +picture, randomly taken from the internet: + +[![bamboo.png](/img/thumb/20150609-bamboo.png)](/img/20150609-bamboo.png) + +`colors` allow you to choose the number of clusters you want to see on the +output, so in our case, we'll output 16. It's possible that `colors` don't +output the number of clusters you asked for. You can "force" outputing empty +clusters with `-e`. + +![default output](/img/20150609-colors0.png) + +Then you can choose how to set your clusters (from the hue domain or pixel space +at the time of writing). Another solution when you don't get the number of +colors you asked for (in my case, I only got 12 colors with -h), is to just ask +for more, and truncate the output. It might give better colors than with `-e` +sometimes. + +![output from hue](/img/20150609-colors1.png) +![output from pix](/img/20150609-colors2.png) + +And then you can randomize the output, if you feel in the mood! You could also +try using the [k-medians](https://en.wikipedia.org/wiki/K-medians) method, which +takes longer but provides a better output regarding the initial file + +![output random](/img/20150609-colors3.png) + +Try different pictures and flag combinations for better results! + +Once you have your output of choice, you can export it as an XRDB colorscheme +with the following script: + + #!/bin/sh + + CPT=0 + while read HEXCODE; do + printf '*color%d: %s\n' "$CPT" "$HEXCODE" + CPT=$(expr $CPT + 1) + done | column -t + +This will allow live theme trying with the following command: + + colors -n 16 bamboo.png | toxrdb | xrdb -merge + +Another nice way I found to create colorscheme is by randomizing the colors from +the hue domain, resulting in a monochromatic scheme that fits entirely you +wallpaper. This works by outputing 32 colors, extracting the 16 colors in the +middle and randomizing them. this way, your colors will not be too dark or too +light. + +![output neat](/img/20150609-colors4.png) + +You can then make a script to change your wall every now and then, and change +the colorscheme on the fly. Your colorscheme will ALWAYS match your current +mood! + +<video controls> + <source src="/vid/20150609-matchlook.webm" type="video/webm"> +</video> + + +**Keep tweaking!** + +<!-- vim: set ft=markdown ts=4 et tw=80: --> diff --git a/config.mk b/config.mk @@ -25,7 +25,9 @@ PAGES = index.html \ 2014/12/so-tox-me-maybe.html \ 2015/01/you-are-the-wm.html \ 2015/02/do-you-gopher.html \ - 2015/03/under-wendys-dress.html + 2015/03/under-wendys-dress.html \ + 2015/04/the-wrong-sysadmin.html \ + 2015/06/vomiting-colors.html FEEDS = rss/feed.xml EXTRA = css img vid data errors favicon.ico diff --git a/index.txt b/index.txt @@ -1,3 +1,5 @@ +* 0x0017 - [Vomiting colors](/2015/06/vomiting-colors.html) +* 0x0016 - [The wrong sysadmin](/2015/04/the-wrong-sysadmin.html) * 0x0015 - [Under Wendy's dress](/2015/03/under-wendys-dress.html) * 0x0014 - [Do you gopher ?](/2015/02/do-you-gopher.html) * 0x0013 - [You are the WM](/2015/01/you-are-the-wm.html)