summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-04-06 21:44:40 -0400
committerluxagraf <sng@luxagraf.net>2020-04-06 21:44:40 -0400
commit39176357654f831b049165c071cec3d965e49111 (patch)
tree565ffa6aa193dbc89a8cbf08bbf22d015bf11407 /src
parent1fb454edddf5f62374b119b1a7a171909aeda414 (diff)
archived old stuff and added pdfs and walks
Diffstat (limited to 'src')
-rw-r--r--src/guide-to-switching-i3-to-sway.txt132
-rw-r--r--src/qutebrowser-notes.txt17
-rw-r--r--src/ranger.txt63
3 files changed, 195 insertions, 17 deletions
diff --git a/src/guide-to-switching-i3-to-sway.txt b/src/guide-to-switching-i3-to-sway.txt
new file mode 100644
index 0000000..33e7742
--- /dev/null
+++ b/src/guide-to-switching-i3-to-sway.txt
@@ -0,0 +1,132 @@
+I recently made the switch from the [i3 tiling window manager](https://i3wm.org/) to [Sway](https://swaywm.org/), a Wayland-based i3 clone. I still [run Arch Linux on my personal machine](/src/why-i-switched-arch-linux), so all of this is within the context of Arch.
+
+I made the switch for a variety of reasons. There's the practical: Sway/Wayland gives me much better battery life on my laptop. As well as the more philosophical: Sway's lead developer Drew Devault's take on code is similar to mine[^1] (e.g. [avoid traumatic changes](https://drewdevault.com/2019/11/26/Avoid-traumatic-changes.html) or [avoid dependencies](https://drewdevault.com//2020/02/06/Dependencies-and-maintainers.html)), and after reading his blog for a year he's someone whose software I trust.
+
+I know some people would think this reason ridiculous, but it's important to me that the software I rely on be made by people I like and trust. Software is made by humans, for humans. The humans are important. And yes, it goes the other way too. I'm not going to name names, but there are some theoretically good software out there that I refuse to use because I do not like or trust the people who make it.
+
+When I find great software made by people who seem trustworthy, I use it. So I switched to Sway and it's been a good experience.
+
+Sway and Wayland have been very stable in my use. I get about 20 percent more out of my laptop battery. That seems insane to me, but as someone who [lives almost entirely off solar power](/1969-dodge-travco-motorhome) it's a huge win I can't ignore.
+
+### Before You Begin
+
+I did not blindly switch to Sway. Or rather I did and that did not go well. I switched back after a few hours and started doing some serious searching, both the search engine variety and the broader, what am I really trying to do here, variety.
+
+The latter led me to change a few tools, replace some things, and try some new work flows. Not all of it was good. I could never get imv to do the things I can with feh for instance, but mostly it was good.
+
+One thing I really wanted to do was avoid XWayland (which allows apps that need X11 to run under Wayland). Wherever I could I've opted for applications that run natively under Wayland. There's nothing wrong with XWayland, that was just a personal goal, for fun.
+
+Here's my notes on making the transition to Wayland along with the applications I use most frequently.
+
+##### Terminal
+
+I do almost everything in the terminal. I write in Vim, email with mutt, read RSS feeds with newsboat, listen to music with mpd, and browse files with ranger.
+
+I tested quite a few Wayland-native terminals and I really like [Alacritty](https://github.com/alacritty/alacritty). Highly recommended. [Kitty](https://github.com/kovidgoyal/kitty) is another option to consider.
+
+That said, I am sticking with urxvt for now. There are two problems for me with Alacritty. First off Vim doesn't play well with the Wayland clipboard in Alacritty. Second, Ranger will not show image previews in Alacritty. Both things work as I would expect in urxvt. I'd like to find a solution to these issues because I like Alacritty better than urxvt, but so far nothing has made Vim work and that one is a deal breaker for me.
+
+##### Launcher
+
+I've always used dmenu to launch apps and grab passwords from pass. It's simple and fast. Unfortunately dmenu is probably never going to run natively in Wayland.
+
+I tested rofi, wofi, and other potential replacements, but I did not like any of them. Somewhere in my search for a replacement launcher I ran across [this post](https://medium.com/njiuko/using-fzf-instead-of-dmenu-2780d184753f) which suggested just calling up a small terminal window and piping a list of applications to [fzf](https://github.com/junegunn/fzf), a blazing fast search tool.
+
+That's what I've done and it works great. I created a keybinding to launch a new instance of Alacritty with a class name that I use to resize the window. Then within that small Alacritty window I call `compgen` to get a list of executables, then sort it to eliminate duplicates, and pass the results to fzf. Here's the code in my Sway config file:
+
+~~~console
+bindsym $mod+Space exec alacritty --class 'launcher' --command bash -c 'compgen -c | sort -u | fzf | xargs -r swaymsg -t command exec'
+
+for_window [app_id="^launcher$"] floating enable, border none, resize set width 25 ppt height 20 ppt, move position 0 px 0 px
+~~~
+
+These lines together will open a small terminal window in the upper left corner of the screen with a fzf search interface. I type, for example, "dar" and Darktable comes up. I hit return, the terminal window closes, and Darktable launches. It's as simple as dmenu and requires no extra applications (since I was already using fzf in Vim).
+
+##### Browsers
+
+I mainly use [qutebrower](https://qutebrowser.org/), supplemented by [Vivaldi](https://vivaldi.com/)[^2] for research because having split screen tabs is brilliant for research. I also use [Firefox Developer Edition](https://www.mozilla.org/en-US/firefox/developer/) for any web development work, because the Firefox dev tools are far superior to anything else.
+
+Qutebrowser and Firefox work great under Wayland. In the case of qutebrowser though you'll need to set a few shell variables to get it to start under Wayland, out of the box it launches with XWayland for some reason. Here's what I added to `.bashrc` to get it to work:
+
+~~~bash
+export XDG_SESSION_TYPE=wayland
+export GDK_BACKEND=wayland
+~~~
+
+One thing to bear in mind if you do have a lot of X11 apps still is that with this in your shell you'll need to reset the `GDK_BACKEND` to X11 or those apps won't launch. Instead you'll get an error, `Gtk-WARNING **: cannot open display: :0`. To fix that error you'll need to reset `GDK_BACKEND=x11`, then launch your X11 app.
+
+There are several ways you can do this, but I prefer to override apps in `~/bin` (which is on my $PATH). So, for example, I have a file named `vivaldi` in `~/bin` that looks like this:
+
+~~~bash
+#! /bin/sh
+GDK_BACKEND=x11 vivaldi-stable
+~~~
+
+Alternately you could just create a bash alias like `alias vivaldi-stable="GDK_BACKEND=x11 vivaldi-stable"`, but I prefer my `~/bin` method since I override a bunch of other apps too for other reasons and this way everything is in one spot.
+
+Note that for me this is easier, because the only apps I'm using that need X11 are Vivaldi and Slack. If you have a lot of X11 apps, you're probably better off making qutebrowser the special case by launching it like this:
+
+~~~bash
+GDK_BACKEND=wayland qutebrowser
+~~~
+
+##### Clipboard
+
+I can't work without a clipboard manager, I keep the last 200 things I've copied, and I like to have things permanently stored as well.
+
+Clipman does a good job of saving clipboard history.
+
+You need to have wl-clipboard installed since Clipman reads and writes to and from that. I also use wofi instead of the default dmenu for viewing and searching clipboard history. Here's how I set up clipman in my Sway config file:
+
+~~~bash
+exec wl-paste -t text --watch clipman store --max-items=60 --histpath="~/.local/share/clipman.json"
+bindsym $mod+h exec clipman pick --tool="wofi" --max-items=30 --histpath="~/.local/share/clipman.json"
+~~~
+
+Clipman does not, however, have a way to permanently store bits of text. That's fine. Permanently stored bits of frequently used text are really not all that closely related to clipboard items and lumping them together in a single tool isn't a very Unix-y approach. Do one thing, do it well.
+
+For snippets I ended up bending [pet](https://github.com/knqyf263/pet), the "command line snippet manager" a little and combining it with the small launcher-style window idea above. So I store snippets in pet, mostly just `printf "my string of text"`, call up an Alacritty window, search, and hit return to inject the pet snippet into the clipboard. Then I paste it were I need it.
+
+##### Volume Controls
+
+Sway handles volume controls with pactl. Drop this in your Sway config file and you should be good:
+
+~~~bash
+bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
+bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
+bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
+bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
+~~~
+
+##### Brightness
+
+I like [light](https://github.com/haikarainen/light) for brightness. Once it's installed these lines from my Sway config file assign it to my brightness keys:
+
+~~~bash
+bindsym --locked XF86MonBrightnessUp exec --no-startup-id light -A 10
+bindsym --locked XF86MonBrightnessDown exec --no-startup-id light -U 10
+~~~
+
+### Quirks, Annoyances And Things I Haven't Fixed
+
+There have been surprisingly few of these, save the Vim and Ranger issues mentioned above.
+
+I haven't found a working replacement for xcape. The only thing I used xcape for was to make my Cap Lock key dual-function: press generates Esc, hold generates Control. So far I have not found a way to do this in Wayland. There is ostensibly [caps2esc](https://gitlab.com/interception/linux/plugins/caps2esc), but it's poorly documented and all I've been able to reliably do with it is crash Wayland.
+
+I miss xcape. I've reverted to `inoremap jj <Esc>` for vim, but if you have a solution, please do let me know in the comments.
+
+I've been using Waybar as a status bar and it works well enough. To be honest I haven't put in the time to get it exactly how I want it, but it's close enough. My one gripe is that Slack doesn't show up in the icon tray, but I hate Slack and only use it because of work, so my motivation to debug that issue is very low.
+
+Surprisingly, those are the only problems I can think of right now. I've been using Sway exclusively for almost two months now and I have no reason or desire to ever go back.
+
+### Helpful pages:
+
+- **[Sway Wiki](https://github.com/swaywm/sway/wiki)**: A good overview of Sway, config examples (how to replicate things from i3), and application replacement tips for i3 users (like this fork of [redshift](https://github.com/minus7/redshift/tree/wayland) with support for Wayland).
+- **[Arch Wiki Sway Page](https://wiki.archlinux.org/index.php/Sway)**: Another good Sway resource with solutions to a lot of common stuff: set wallpaper, take screenshots, HiDPI, etc.
+- **[Sway Reddit](https://old.reddit.com/r/swaywm/)**: There's some useful info here, worth searching if you run into issues. Also quite a few good tips and tricks from fellow Sway users with more experience.
+- **[Drew Devault's Blog](https://drewdevault.com/)**: He doesn't always write about Sway, but he does give updates on what he's working on, which sometimes has details on Sway updates.
+
+
+[^1]: That's not to imply there's anything wrong with the i3 developers.
+
+[^2]: Vivaldi would be another good example of me trusting a developer. I've been interviewing Jon von Tetzchner for many years, all the way back to when he was at Opera. I don't always see eye to eye with him (I wish Vivaldi were open source) but I trust him, so I use Vivaldi. It's the only software I use that's not open source (not including work, which requires quite a few closed source crap apps).
diff --git a/src/qutebrowser-notes.txt b/src/qutebrowser-notes.txt
deleted file mode 100644
index f7887e6..0000000
--- a/src/qutebrowser-notes.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-handy commands:
- :download
-
-## shortcuts
-xo - open url in background tab
-go - edit current url
-gO - edit current url and open result in new tab
-gf - view source
-;y - yank hinted url
-;i - hint only images
-;b - open hint in background tab
-;d - download hinted url
-PP - Open URL from selection in new tab
-ctrl+a Increment no. in URL
-ctrl+x Decrement no. in URL
-
-Solarized theme: https://bitbucket.org/kartikynwa/dotty2hotty/src/1a9ba9b80f07e1f63b740da5e6970dc5a97f1037/qutebrowser.py?at=master&fileviewer=file-view-default
diff --git a/src/ranger.txt b/src/ranger.txt
new file mode 100644
index 0000000..f66a707
--- /dev/null
+++ b/src/ranger.txt
@@ -0,0 +1,63 @@
+[Ranger](http://nongnu.org/ranger/) is a terminal-based file browser with Vim-style keybindings. It uses ncurses and can hook into all sorts of other command line apps to create an incredibly powerful file manager.
+
+If you prefer a graphical experience, more power to you. I'm lazy. Since I'm already using the terminal for 90 percent of what I do, it make sense to not leave it just because I want to browse files.
+
+The keyword here for me is "browse." I do lots of things to files without using Ranger. Moving, copying, creating, things like that I tend to do directly with `cp`, `mv`, `touch`, `mkdir` and so on. But sometimes you want *browse* files, and in those cases Ranger is the best option I've used.
+
+That said, Ranger is something of a labyrinth of commands and keeping track of them all can be overwhelming. If I had a dollar for every time I've searched "show hidden files in Ranger" I could buy you a couple beers (the answer, fellow searchers, is `zh`).
+
+I'm going to assume you're familiar with the basics of movement in Ranger like `h`, `j`, `k`, `l`, `gg`, and `G`. Likewise that you're comfortable with `yy`, `dd`, `pp`, and other copy, cut, and paste commands. If you're not, if you're brand new to ranger, check out [the official documentation](https://github.com/ranger/ranger/wiki/Official-user-guide) which has a pretty good overview of how to do all the basic stuff you'll want to do with a file browser.
+
+Here's a few less obvious shortcuts I use all the time. Despite some overlap with Vim, I do not find these particularly intuitive, and had a difficult time remembering them at first:
+
+- `zh`: toggle hidden files
+- `gh`: go home (`cd ~/`)
+- `oc`: order by create date (newest at top)
+- `7j`: jump down seven lines (any number followed by j or k will jump that many lines)
+- `7G`: jump to line 7 (any number followed by `G` will jump to that line
+- `.d`: show only directories
+- `.f`: show only files
+- `.c`: clear any filters (such as either of the previous two commands)
+
+Those are handy, but if you really want to speed up Ranger and bend it to the way you work, the config file is your friend. What follows are a few things I've done to tweak Ranger's config file to make my life easier.
+
+###Ranger Power User Recommendations
+
+Enabling line numbers was a revelation for me. Open `~/.config/ranger/rc.conf` and search for `set line_numbers` and change the value to either `absolute` or `relative`. The first numbers from the top no matter what, the `relative` option sets numbers relative to the cursor. I can't stand relative, but absolute works great for me, YMMV.
+
+Another big leap forward in my Ranger productivity came when I discovered local folder sorting options. As noted above, typing `oc` changes the sort order within a folder to sort by date created[^1]. While typing `oc` is pretty easy, there are some folders that I *always* want sorted by date modified. That's easily done with Ranger's `setlocal` config option.
+
+Here's a couple lines from my `rc.conf` file as an example:
+
+~~~bash
+setlocal path=~/notes sort mtime
+setlocal path=~/notes/reading sort mtime
+~~~
+
+This means that every time I open `~/notes` or `~/notes/reading` the files I've worked with most recently are at the top (and note that you can also use `sort_reverse` instead of `sort`). That puts the most recently edited files right at the top where I can find them.
+
+Having my most recent notes at the top of the pane is great, but what makes it even more useful is having line wrapped file previews so I don't even need to open the file to read it. To get that I currently use the latest Git version of Ranger which I installed via [Arch Linux's AUR](https://aur.archlinux.org/packages/ranger-git/).
+
+This feature, which is invaluable to me since one of my common use cases for Ranger is quickly scanning a bunch of text files, has been [merged to master](https://github.com/ranger/ranger/pull/1322), but not released yet. If you don't [use Arch Linux](/src/why-i-switched-arch-linux) you can always build from source, or you can wait for the next release which should include an option to line wrap your previews.
+
+###Bookmarks
+
+Part of what makes Ranger incredibly fast are bookmarks. With two keystrokes I can jump between folders, move/copy files, and so on.
+
+To set a bookmark, navigate to the directory, then hit `m` and whatever letter you want to serve as the bookmark. Once you've bookmarked it, type ``<letter>` to jump straight to that directory. I try to use Vim-like mnemonics for my bookmarks, e.g. ``d` takes me to documents, ``n` takes me to `~/notes`, ``l` takes me to the dev folder for this site, and so on. As with the other commands, typing just ``` will bring up a list of your bookmarks.
+
+###Conclusion
+
+Ranger is incredibly powerful and almost infinitely customizable. In fact I don't think I really appreciated how customizable it was until I wrote this and dug a little deeper into all the ways you can map shell scripts to one or two character shortcuts. It can end up being a lot to keep track of though. I suggest learning maybe one or two new shortcuts a week. When you know longer have to think abut them, move on to the next couple.
+
+Or you can do what I do, wait until you have something you want to do, but don't know how, figure out how to do it, then write it down so you remember it.
+
+####Shoulders Stood Upon
+
+* [Dquinton's Ranger setup details](http://dquinton.github.io/debian-install/config/ranger.html) - I have no idea who this person is, but their Ranger setup and detailed notes was hugely helpful.
+* [Ranger documentation](https://ranger.github.io/ranger.1.html) - The docs have a pretty good overview of the options available, though sometimes it's challenging to translate that into real world use cases.
+* [Arch Wiki Ranger page](https://wiki.archlinux.org/index.php/Ranger) - Where would we be without the Arch Wiki?
+
+
+
+[^1]: In fact, just type `o` and you'll get a list of other sorting options (and if you know what `normal` means, drop me a comment below, I'm still trying to figure out what that means).