Notes from NetBSD

3 January 2021

Greetings to all my (non-existent) readers from NetBSD, where I am currently writing this blog entry. I originally installed NetBSD 9.0 on a spare drive in my main desktop (which normally runs GhostBSD) months ago to play around with, but after spending a few hours with it, then booting back to GhostBSD the next day for work, I hadn’t revisited it until now.

I had some time off from work this week and used a small amount of it to upgrade my NetBSD install to 9.1 and finish configuring it to something similar to My normal desktop configuration that I use on other OS’s:.

You can tell its NetBSD by the wallpaper.
You can tell its NetBSD by the wallpaper.

The following are my notes and observations so far.

NetBSD 9.0 -> 9.1 Upgrade

Reading about the upgrade process made it look trivially easy– just run sysupgrade, answer a few questions about config file merges and it will take care of the rest. In practice though, as a NetBSD n00b it didn’t go quite so smoothly.

  • After installing sysupgrade and trying to run it, and realizing it wasn’t in my path, I managed to get it running with the command:
    sudo /usr/pkg/sbin/sysupgrade auto \
      http://cdn.NetBSD.org/pub/NetBSD/NetBSD-9.1/amd64
    

    However it quickly exited with a 404 error when trying to download the first file. It was looking for a .tgz file but the files on the site were .tar.xz. I had to edit one line in the sysupgrade script:

shtk_config_set ARCHIVE_EXTENSION "tgz"

Replacing the tgz with .tar.xz fixed the problem and everything downloaded and extracted, erroring out near the end when trying to run postinstall and etcupdate. I quickly discovered that those files were also in /usr/pkg/sbin and that manually using the full path when running sysupgrade isn’t enough. Adding the directory to my path took care of the problem.

It did error out once more, but helpfully gave me the exact command I needed to run to fix it, and afterwards the process completed smoothly. After the upgrade was complete, I celebrated by upgrading all my packages and rebooting, and was relieved to be greeted with NetBSD 9.1

A Few Small Problems (And Their Solutions)

While setting up my environment after the upgrade, I had to troubleshoot a few problems

  • First every now and then all my commands would start failing with error messages like “Too Many Open Files”. I discovered that Firefox had a ton of file descriptors over and that killing it would resolve the issue for a bit before it came back. Based on (This advice)[https://minux.hu/solving-too-many-open-files-problem-netbsd] I tried increasing my ulimit -n from the default of 1024, to around 3400 and the problem has not occurred again. I’m still not sure if this is a descriptor leak in Firefox, and I’ll eventually hit the new maximum, or if Firefox, for some reason, just needs to have 1000 file descriptors open.

  • While trying to install (Jekyll)[https://jekyllrb.com/] so I could work on this blog, I was getting SSL certificate errors trying to download the Ruby Gems. While trying to troubleshoot, I attempted to use curl to download a certificate and had a similar error there. I eventually found I needed to run mozilla-rootcerts install and after that it worked.

  • I like to run Xfce with the Greybird theme, which gives me the nice dreary looking dark grey panel you see on my screenshot above, however I was unable to find the Greybird theme anywhere in pkgin. I ended up copying the directory /usr/local/share/themes/Greybird/ from my FreeBSD machine to ~/.local/share/themes/Greybird/ on my NetBSD system, and then was able to select and use the theme.

  • I wanted to download some add-ons for Firefox, but when I went to the extension page in Firefox to try to download some, it gives an ‘Unsupported Platform’ error. Luckily, the platform is just communicated to the server as a URL parameter, and I was able to edit it in place, tell them I was FreeBSD, and run the addon I needed fine.

A Few (as of yet) Unsolved Problems

  • While FreeBSD and GhostBSD have no problem with it, NetBSD doesn’t seem to like my Plantronics USB Headset. I’m not able to get any audio from it, and I see a message in dmesg: uaudio1: autoconfiguration error: ignored audio interface with 2 endpoints. Fortunately I was able to get audio output (though not input) through the built in sound card, so at least I have that much going for me. I’ve posted a plea for help on the UnitedBSD Forum but haven’t yet figured anything out.

  • I also have not yet managed to get my USB SmartCard Reader recognized. As on Free/GhostBSD and Linux, I installed the opensc and ccid packages and ran pcscd -df from the command line, but it never sees my reader or card.

  • I like to set up my desktop to have certain hotkeys that run scripts which open an application and place it at a certain location and size on a certain desktop. I accomplish this with calls to the wmctrl tool, but find these scripts don’t work on NetBSD. Further investigation shows that wmctrl -l does not list all the available Windows open on my desktop, just some of them, so this is probably related. I haven’t yet been able to discern a pattern or find a cause.

  • My desktop has Nvidia graphics, and it seems much smoother on GhostBSD. If I’m not mistaken, Ghost/FreeBSD has a binary driver from Nvidia for this, while NetBSD uses Noveueau, which is probably the cause. Currently I have visible screen tearing and some temporary redraw glitches– as I drag one window in front of another the redrawing of the background window and motion of the dragged window is slow and flickery. I haven’t spent any time yet seeing if this can be improved yet.

  • NetBSD seems slower and a bit laggy at times compared to GhostBSD on the same system, but its hard to say how much of this is NetBSD, and how much is that I’m running GhostBSD from an SSD and NetBSD from a Hard Drive. I can’t blame the OS for slower loading of programs, but doing things that shouldn’t hit the disk at all can seem slower.

  • I’ve had one full OS hang in my first day of using it, I was trying to change my Xfce background image when the mouse and everything else hung. I had to hard reboot and on startup, NetBSD has a kernel core dump for me.

  • I’ve also managed to ‘soft hang’ the system a few times trying to quit X or change to a terminal and getting just an unresponsive black screen . I don’t think its really hung here and have the feeling if I had ssh running I would have been able to log in that way still, but as it is I had to reboot to get it back. I”ve had similar issues with Debian GNU/Linux at work and even on FreeBSD on my laptop with an external monitor, so its not just NetBSD that has trouble with this.

  • After leaving FireFox open overnight and coming back the next day, it was super slow and stopped reliably loading pages. I was unable to close it from the GUI and had to pkill and relaunch it.

  • I’m used to using VirtualBox to virtualize a couple of guest Operating Systems that I use for work, but that doesn’t exist on NetBSD. My preliminary reading points to qemu+nvmm as a possibility for this, but I haven’t researched it enough yet or tried it out.

Next Steps

I’ve had a bit of a rough start with NetBSD, a few crashes and a few things I need not working, but I plan to stick with it and see how things shake out. If nothing else its a fun experience to try different things.

I’m back to work (from home) tomorrow after my holiday break. I plan to keep my primary desktop booted into NetBSD and see how far I get with it. Ninety percent of my job at ${WORK} consists of mucking about in terminals on various Linux Servers, which I can do fine in NetBSD since I have openconnect working to connect to my work VPN, and ssh. Most of the rest involves working in a webbrowser, for which the Firefox Nighly provded by NetBSD should be fine. Wireshark and audacity which I often need are both available, and everything else I’d use would be command line tools.

The two things I can’t yet do that I need for work is to access my email (Need SmartCard support working) and Skype, which we use for all our team calls (Need a working headset / microphone). I did test the Skype web client under NetBSD, by setting the UserAgent to Linux Chrome and was able to make a call and hear the remote side (Couldn’t send audio though, since I don’t have microphone support working). Hopefully If I can get that working, this will suffice for work calls, otherwise I can try out running the Linux Skype Client under a virtualized Debian, which is how I do it on other BSDs.

Luckily, I keep my FreeBSD laptop on the desk next to me in my home office, so my plan for tomorrow is to bring up my email and skype on that and use NetBSD on my workstation for everything else. If things seriously go sideways, I can always boot back into GhostBSD. Fingers crossed.

How I Actually USE my Unix Desktop

30 December 2020

Introduction

Sometimes when I’m bored I’ll browse /r/unixporn and ogle the attractive nut impractical Unix desktop layouts. /r/usabilityporn is better as far as seeing desktops that someone might actually make use of beyond setting them up in a virtual machine and taking a screenshot.

However, even there, you can’t really get a good idea of how they might actually use the desktop environments they are posting. What I always want to know is “How do you use your desktop? What hot keys, what software do you lean on? How does it feel to exist in that environment? Why do you choose this instead of something else?” Alas, these questions are rarely answered beyond perhaps a list of themes and software shown.

So in the spirit of “No one writes them like they used to, so it might as well be me”, I wrote this post to provide way more information about my own desktop use than anyone in their right mind would ever care to know.

One interesting thing to me, is how much more the desktop environment affects the day to day usage experience than the OS itself does. The screenshots on this post are taken from my GhostBSD Desktop, but I have FreeBSD, NetBSD, and Debian GNU/Linux installs use pretty much the same configuration, so for day-to-day usage they feel a lot like the same system until I need to go and install packages or something.

Part 1: The Look

An empty, clean desktop. I never see this in real life.
An empty, clean desktop. I never see this in real life.

Desktop Environment

My desktop starts off with Xfce, mostly for the Xfce4-panel, which I like because it can be simply configured to exactly how I want it to look and act. I remember trying both Gnome and KDE back in the late 1990’s but found them both heavier and more opinionated than I liked, so I pretty much always used used various window managers instead of a full desktop environment, culminating in my discovery of the Notion Window Manager, which at the time was called Ion (Notion is basically “Not Ion” and was forked when the original developer of Ion took his ball and went home).

I used Notion on all my desktops from 2002-2018, and got really used to its workflow, so even though I’m no longer using it, I can see echoes of my usage of it in my current configurations in how I open and close windows and how I layout my applications. In 2018 I was reinstalling Debian at work after a hard drive failure, and decided to try Xfce, pretty much on a lark. I’d heard it was much lighter than Gnome and KDE, and that it was fairly configurable and not as opinionated as those two. Notion is all workflow and no eye candy at all, which is pretty much how I like it, but perhaps maybe a little eye candy would be ok. I find having a nice desktop background, window decorations and a status bar changes the way I feel about the computer I’m using, its nothing huge, but perhaps like the difference in working in a nice office versus in a run down, but efficiently laid out warehouse (I’ve done both).

I have no use at all for things like File Managers, or icons living on my desktop, so while Xfce is the basis of my work environment, my interaction with it is limited primarily to xfce4-panel and occasional use of a utility like the Xfce Screenshot tool (which I used to take the images for this blog post).

I’m also not been big on busy, complicated background wallpapers. When using Notion for years there was no concept of a background image, and on Windows I just use plain blue. I am a stickler for throwing up the logo of the OS I’m currently using though, as long as its not something I’m embarrassed of (Perhaps the reason my MS Windows backgrounds tend to just be plain blue). My FreeBSD laptop background is black with the shiny red daemon-head, my Debian desktop is blue with the Debian Spiral, etc. I turn off all icons on my desktop and never use them and I have better ways to quick launch something.

Panel

I’m currently using xfce4-panel, part of Xfce. A few times I’ve considered porting my panel settings to something standalone, as it feels a bit silly to pull in an entire desktop environment that I mainly just use to set a background wallpaper and display a panel. I could probably do just as well with something like feh + tint2, but Xfce is pretty light weight anyway and hasn’t been a problem for me. Its also one of the two default flavors of GhostBSD, the other being Mate).

My preferred panel setup, is, oddly enough, reminiscent of the setup Microsoft introduced in Windows 95. You can usually tell when a *nix user comes from a Windows or Mac background based on their preferred panel setup, though in my case I actually started using Linux a few years before Windows 95 was released. I’m guessing I originally picked up an affinity for this style from with fvwm95 window manager, which I used for a few years in the 1990’s.

One thing I’ve never liked though, either from Windows, or any of the X11 Desktop environments that copied it, is the start menu with a bunch of programs in it. I hate it even when they make it a ‘right click on the desktop’ menu instead. Much like my disdain for icons on the desktop, I have better ways to launch a program than to scroll through a start menu. In place of a start menu, I put two launcher buttons for the two Windows I tend to launch the most– Chromium and xterm. The ‘up arrow’ next to Chromium, also grants me the ability to also run Firefox or the Linux version of Google Chrome (under Linux emulation) for those sites where Chromium just won’t cut it. The empty folder icon hides all my programs and shows me the desktop, which actually serves no purpose other than to let me stare at the calming blue desktop when I get stressed by how many Windows I have open, since In addition to not storing icons on my desktop, I rarely use and never configure the Xfce ‘right click on the desktop’ menu.

The rest of my panel is extremely standard stuff, icons for all my open programs, a view of my four workspaces, which I’ll write more about below, a notification center, which mainly is just to let me know when GhostBSD has updates for me to install– which it does in the screenshot, and the current time. My laptop version of my configuration also has a battery status icon between the workspaces and time. I’ve seen a lot of really cool status bar setups people do with things like polybar, but truthfully, just isn’t a lot of information that I want to stare at all the time. Instead I have hot keys that pop up a status bubble so I can quickly peak at something like my Load or CPU Temperature if I care to see it.

Window Manager

There’s nothing wrong with the default Xfwm window manager that comes with Xfce, and I sometimes wonder if I’m just a difficult person who just likes to make things complicated, but I always replace the default Xfwm window manager with OpenBox. I originally moved to OpenBox because Xfwm had some visual glitches with the Intel Graphics drivers on FreeBSD 12.1, but soon moved my other systems to it as well– It looks great (with the Bear2 theme), and I like how it briefly pops up the name of the workspace when you change workspaces. This, along with the fact that unlike Xfwm, it won’t let me Go “Right” from the Right most desktop to get back to the left most, helps with my feeling centered in a ‘physical’ layout, as if my workspaces are physical things in spaces. Without these features, I feel less grounded in my system and tend to forget what workspace I’m in at any given time.

A highly staged screenshot showing dmenu and some applications. Everyone runs neofetch at all times, right?
A highly staged screenshot showing dmenu and some applications. Everyone runs neofetch at all times, right?

The default Window decorations from OpenBox provide me all I need- standard minimize, maximize and close buttons. There’s also a right click menu I can use to move the window to a different workspace, or make it ‘always on top’. I also have hot keys to do these things, I tend to use mouse or keyboard for this interchangably depending on where my hands happen to be. If I’m scrolling through a webpage with the mouse and want to move the browser to another workspace, I’ll use the right click menu. If I’m typing in an xterm and want to do the same, I’ll use the hotkey.

One other thing when it comes to Window Managers that is a must have for me is ‘focus follows mouse’. Anything else just seems wrong, because it is.

Part 2: The Hotkeys

Far more important to me than the visual elements in a desktop, are the keybindings. Most important of course, are the keybindings that actually get used. Between my desktop environment, Window Manager, terminal, GNU Screen, and the software I actually run underneath all that. There are a ton of available keybindings that I’ve never committed to memory or at least my hands won’t reach for automatically. Its the keybindings you use, that are important, not the ones configured.

Some of the keybindings I use are configured through OpenBox, but whenever possible I like to configure them in xbindkeys. It’s an older program, but I prefer it as opposed to configuring hotkeys inside my window manager or desktop environment whenever possible for two reasons: First, I can take it with me and wouldn’t have to re-configure everything If I want to try out a new desktop environment or window manager. Second, it feels more unixy to have a standalone daemon that handles the hotkeys and doesn’t mess with anything else. It has a simple configuration file format, much nicer than editing XML to configure OpenBox, or clicking around in some GUI.

Whenever possible I bind my desktop Hotkeys to use the “Windows Key”. Its there on the keyboard anyway, and nothing else uses it, so it doesn’t interfere with hotkeys I want to send to my applications. The main exception is the hotkeys I use to change to a different workspace, which are Bound to Ctrl-Arrow Keys to go right,left, up or down. This can sometimes conflict with keys that applications want to use, but I prefer it over the OpenBox default (which If i recall is Ctrl+Shift+Arrow), as I use these a ton, and having it on ctrl also allows me to use the right ctrl button and do the hotkey with just my right hand. Also, Win-Arrow is already taken by the hot key to change which window on the desktop is active. My most commonly pressed HotKeys go something like:

Ctrl + Arrow Change to a different workspace
Alt + Ctrl + Arrow Change to a different workspace and bring the focused window with me
Win + Arrow Change to a different window in this workspace
Win + c Close Focused Window
Win + x Open xterm
Win + z Open dmenu- Lets me run any program by typing the name (with tab completion)
Win + b Show Battery / CPU status (CPU Frequency, Temperature, Current Drain, Time Left)
Win + v Prompt me for a password and connect my VPN to ${WORK}
Win + t Open xterm and run top. Upon hitting ESC to quit top, the window will close
Win + Shift + letter open xterm and ssh to the server at work whose name begins with said letter

In addition I have several hot keys bound to open specific programs and put them on specific workspaces at preset locations and sizes, but I’ll write more about those in the next section. With all the possible hotkeys betweeen those I’ve configured and those that are preconfigured for me, writing it all down, its suprising how few it takes to add up to 90% of my usage.

There are four main ways I launch programs. For xterms and chromium, I have a launcher icon I can click in my panel. More commponly I’ll spawn an xterm with the Win+x hotkey and run whatever I want inside it. If I don’t want or need a controlling xterm sitting around for a GUI program, I’ll click Win+Z to bring up a bar at the top of the screen, type the program name in, and hit enter to run it. I use (dmenu)[https://tools.suckless.org/dmenu/] from suckless to for this. I actually use the run_recent script for dmenu to show me the most recent programs I’ve launched from there. It also allows me to append a semicolon to a command to automatically run it in an xterm, though if I’m going to go that far, I’m more likely just to spawn an xterm with Win+X and run it from there.

One important, but invisble aspect of my workflow, is that I have OpenBox configured to always spawn new programs under the mouse. This, coupled with the focus-follow-mouse setting means that I can open an xterm with Win-X, begin typin in it immediately, then close it with Win+C when done with it without my hands ever leaving the keyboard, So “Win-X ls Win-C" shows me all the files in my home directory in an xterm and then gets rid of the window when I'm done looking. Nothing about my configuration is all that custom, but its simple configuration options in combination like that that make me love using this environment. I feel as if I'm using a workstation designed for me, the way I want it to work, not something designed for how some UX designer things I should want it to work.

Part 3: The Programs

The programs I spend the most time in, ordered approximately from most to least:

XTerm

I easily spend more time in an XTerm than any other program. There’s plenty of other terminals of course, and every desktop has its own default terminal, but I find they are really only useful for typing pkg install xterm or apt install xterm. There’s something about good old xterm that just feels comfortable. I use it with pretty much default settings. I just throw a couple of lines in my .Xresources and I’m good to go:

xterm*background: black
xterm*foreground: lightgray
xterm*faceName: monospace:pixelsize=12

Despite using XTerm so much, I can’t say I’m a power user of it, in fact, the XTerm hotkeys I can think of off the top of my head that I use regularly are Shift-Insert to paste the X Selection buffer, and Shift-PgUp to scroll back and see something I’ve missed.

Every now and then I’ll think that I should really start using tabs in my terminals, and will install Suckless tabbed and start using it for a few days, but I always fall out of using it. I guess I don’t really need it.

Chromium

Chromium is currently my standard ‘View some random page’ web browser. I used to mainly use FireFox, and think that in some ways I still prefer Firefox, but I use Firefox in a specific way on my system which leaves Chromium for everything else. I don’t have a lot to say about Chromium, I tend to think of web browsing as a mousy activity as opposed to using a lot of keyboard activity, so I don’t use a ton of chromium hotkeys, except for Ctrl+L to focus the URL bar, Alt-Left and Alt-Right to navigate back and forth in history, and Ctrl-Tab and Ctrl-Shift-Tab to change tabs. Pretty much everything else I do via mouse.

I just realized that I don’t actually have a hot key to open Chromium, instead I have Win+J which opens up Chromium, moves it to my second Workspace (the Browsers Workspace), maximizes, it, and loads up my Work JIRA instance (Hence the J). I run this shortly after starting up my computer and from there, to view random sites in Chromium, I just use the New Tab or New Window in Chromium.

Firefox

For work I have to use an annoying “Secure” email client which is basically a VMWare Horizon Virtual Windows Machine running Outlook. For “Security Reasons” Cut and Paste is disabled and its painful to actually get access to files I’m sent. The actual VMWare Client doesn’t support my Operating Systems of choice, but luckily the Web Client does work for me, more or less . While It does work in Chromium, I have better luck with it in Firefox. Connecting to my email requires the use of a SmartCard reader and an ID card.

To make The Website reliably access the SmartCard, I have a special script which first kills any open firefox, then kills and restarts the opensc daemon that talks to the Smartcard reader, before starting Firefox and pointing at the Webclient URL. This causes it to pop up a prompt for my PIN. This only works reliably by killing and restarting both firefox and opensc before every use. I’ve had this problem in both Linux and BSD, so I’ve just gotten used to it. This is the reason I can’t use firefox for other uses, it seems if I leave other firefox windows open, restarting the email window dowsn’t work reliably.

I have this bound to Win-H (For Horizon)

Wireshark

I’ve been using Wireshark from back when it was called Ethereal. I do a lot of TCP/IP, Protocol development, and VoIP stuff for work, so after Terminals and a Web Browser, this is the most important program for me. Usually I just run this right from the XTerm I’m working in, eg ‘scp server:whatever.pcap . && wireshark whatever.pcap’, though othertimes I’ll run it from dmenu.

VirtualBox

I’ve always got a couple of virtual machines running. On my BSD workstations, I’ve got an old 32-bit Windows XP running an ancient version of Visual C++ that I still need on occasion to build a change to a legacy product we still support. I also keep a Debian 10 VM running all the time, that I use for running Skype as well as Docker and a few other things. Other than those, I’ll sometimes spin up NetBSD or another Linux distribution I want to check out, but just for fun or curiosity.

For many years, I ran Windows on my personal laptop and used VMWare to run a virtual Linux desktop when I needed to work from home. This worked well since I got the hardware support of Windows (Running on a Laptop with spotty Linux hardware support), but the user environment from Linux, which I prefer. Eventually I bought a different laptop specifically for good Linux/BSD compatability.

When I first moved to FreeBSD, I tried to move to bhyve for virtualization, but I find myself more at home with VirtualBox. The only complaint I have about it is that USB2 and USB3 passthrough isn’t supported on FreeBSD.

Skype

My team uses Skype for all of our conference calls and for ad-hoc group debugging sessions, so its important for me to have a workable client. I’ve had mixed luck with running the Skype Web Client under Free/GhostBSD, so my workaround is to run the Linux client on a Debian VM. Of course on my Debian system I can just run the client directly. I don’t run X11 on my VM though, and often just run this one headless. I have a hotkey (Win-S) which ssh’s into the VM and starts up Skype with X Forwarding for GUI and PulseAudio forwarding over the network for Audio. Its not perfect, but it works good enough for my use. Skype is always running on an out-of-the-way workspace waiting to let me know someone’s calling me.

Audacity

Another program I use a ton for work, mainly when working on codec or Voip stuff. Run some code that decodes or processes some audio. Listen to it in Audacity. It sounds like total Sh*t. Repeat ad-infinitum.

Evince and LibreOffice

Evince to read specifications and standards that are in PDF format. LibreOffice to read them if they are .docx. I pretty much don’t use them for anything but that. If I need to write something, I’ll do it in emacs, maybe with markdown or raw html if it really needs to be formatted.

RhythmBox

Its funny how quickly I’ve run through all the different GUI Applications that I actually ever use. Almost everything I use is just different command line programs running under XTerm. Whenever possible I prefer to install the ‘No X’ version of packages, like emacs, and use it from the terminal instead.

The last GUI app I can think of is that sometimes I’ll open up Rhythmbox and use it to play my music collection while I work (What I still think of as my iTunes Library even though I’m not using iTunes anymore). More commonly I just stream stuff since I’m on an internet connection anyway, but I do still use this from time to time.

Part 4: Monitors and Workspaces

For a long time I was a single monitor purist. While my co-workers monitors seemed to breed before them like rabbits (One guy in my office was using a six monitor system for a while), I insisted on a single monitor directly ahead of me. I’ve especially never liked my co-workers’ dual monitor setups where they spend all day staring directly at the break between two monitors in front of them. These days several of them seem to be replacing their multi-monitor setups with a single monitor very wide monitor which curves around them and makes me nauseous just to look at.

Eventually however, with everyone around me discarding perfectly good monitors. I succumbed to the dual monitor disease myself. My setup is a bit idiosyncratic though, as I insist on a single primary monitor directly in front of me, and a secondary monitor off to the side, and perhaps a bit farther away. I still use only the single monitor to layout and interact with my windows, and leave the secondary monitor to things I’m not expecting to interact much with but just want to keep an eye on.

When working, I almost always have my secondary monitor showing my email client, so I can glance over and see if there’s anything inbound I need to take a look at. The “Secure” email web client I’m forced to use is too secure for features like “Desktop Notifications”. ‘Secure’ and ‘Convenient ‘ tend to be opposing forces. At times I’ll also have a Youtube video playing on that monitor that I’m sort of paying attention to as I work. Everything I drag to that monitor I set the ‘All Desktops’ flag in OpenBox, so the layout is the same on all workspaces. I tend to think of that monitor as being outside my workspace system as I change workspaces only on my primary monitor. Technically this isn’t whats happening, but the end result is the same, and that’s the mental model of it I have.

I’ve played with different numbers of workspaces, but seem to have settled on four, in a two by two grid. My primary workspace is named ‘Main’ and is in the upper-left. This is where I actually get programming, editing, and writing done. To the right, is ‘Browsers’, which funnily enough, is where I generally keep web browsers and documentation. My bottom left is ‘Virtual Machines’, and on the Bottom right, out of the way, is a desktop named ‘Skype’. The workspace names describe what I usually run on each workspace, and correlate to what my hotkeys do (If I start up Skype from a hot key, it will start up on the Skype Workspace automatically). However I’m somewhat fluid on what I actually do with each. Sometimes its easier to bring a browser over to ‘Main’ or an XTerm to ‘Browsers’ if I’m following some directions or specification as I code, and sometimes will pick a non-main workspace to use for some temporary project. I tend to blog in emacs, for example, from the Browser workspace, along side the Browser showing previews of my Markdown.

Part 5: My Workflow

For work, my Hotkey Win-W (W for Work), spawns my two main XTerms on my ‘Main’ Workspace. The left one takes up most of the screen, ssh’s into the main server I develop on, and attaches to my GNU Screen session I keep running their all the time. From there I have different windows in Screen that access my emacs editors, shells, and containers for actually getting work done. The servers my group uses are mostly Debian GNU/Linux, so regardless of what OS I run on my desktop, this is actually where I spend most of my time. On the right I have a narrower XTerm which does the same thing but connects me to an irssi running on the same server for my group’s IRC channels. This is pretty much the same layout I used back with Notion before I switched away to Xfce, and it might as well be a tiled window manager, as their startup-scripts move and size these windows to these locations and I don’t tend to move these windows around.

I really like having all my work stuff running on a server at work under GNU Screen. This means I can work one day in the office, and pick up the next at home, or from my laptop, and connect to the exact same editors, command prompts, etc exactly as I left them. Whenever I reboot my workstation, all I do when I get into X is run Win-V to connect the VPN, Win-W to open my work terminals, and I can continue right where I left off. I’ll usually open Skype, Horizon, and Jira with three more hot keys and I’ve got everything I need ready to go. I’ve experimented with a single hot key to do all of this, but I actually prefer the granularity.

The scripts my hotkeys run all look more or less like this:

title='GNU Screen - Work Server'
echo -e '\033]2;'$title'\007'
wmctrl -r $title -e 0,1920,0,1411,1025
ssh -t <ip address> 'screen -r -x -p1 -A'

Xbindkeys would run it with ‘uxterm -e ~/scripts/work.sh’. Basically open an XTerm, set the title, put it where it belongs, ssh in, and connect to my screen. Very comfortable. The versions I use on my laptop are a bit more complex, as they will detect if I have an external monitor attached, and arrange windows differently if I do. With my laptop, I use the external monitor as my ‘primary’ desktop and the laptop screen just for email, but If I’m using the laptop portably, the laptop becomes the primary monitor, and email goes with “Virtual Machines” on the lower left workspace.

Conclusion

I’m always slowly tweaking things, often I’ll try something out only to revert back as I find I don’t really end up using it, as I have a few times with trying to get used to using tabbed with my xterms. I have a list of a few things I’ve wanted to set up and haven’t yet taken the time to figure out. I want to be able to programmatically open a Window and set it to ‘All Desktops’ instead of just one workspace, but Openbox and wmctl don’t seem to get along in this way. I also need to set up a hot key for enabling and disabling “Keep this Window on Top”. For larger things, I may still decide to change our xfce4-panel for something else.

What I like most about the Linux / Unix desktop experience, is that people are always making new components, desktops, and themes, always adding new configuration options to their software, and even if no project exactly tickles my fancy, the ecosystem becomes a big smorgasbord to pick and choose from. Nothing I use is that far off the beaten path, there is a ton of software that works almost exactly how I want it to. Often I can configure in the changes I want, and if not, I can trivially swap a piece out for another project that does what I want. Add in a small amount of custom scripts I write myself, and I’m pretty much right where I want to be. Worse case scenario, everything I use is Open Source so if necessary I could crack it open and make the changes I want.

I read a lot of articles online that promote the idea of ‘standardizing’ the desktop experience to better compete with Apple or Microsoft. The argument seems to boil down to “Everyone should just get on the same page and use the exact same thing exactly was some entity decides it should work and stop forking and configuring, and rewriting everything to ‘scratch their own itches’”. Fortunately anytime a movement appears that seems to have such a goal, it seems an equal-but-opposite movement occurs with an exodus back to freedom for which I’m grateful.

I like reading about what others are using and configuring for their own use. Hopefully someone out there didn’t find this post to be a complete waste of time. Unlikely perhaps, but hopefully.

ZFS Saved Me or Screwed Me, Still not Sure Which

22 December 2020

The other day on my GhostBSD workstation, Chromium crashed. This is not a totally strange event for me, but what was strange is that it refused to restart. Running it from a terminal, I saw it was complaining about cache files. Figuring that the cache files had somehow become corrupt, and that they were after all just a cache, I should be able to remove the cache and let it recache stuff on startup, I went to my cache directory and did a mv on it to rename it from Cache to Bad_Cache or something like that, and Chromium happily restarted and started caching to its hearts delight. Problem solved?

I figured I didn’t need this bad cache sitting around and attempted to rm -rf it, only to be greated with an error about Directory not Empty. This was odd, since -rf should basically tell it ‘don’t care if the directory is empty or not, just delete it’. I manually deleted all the files inside the directory, making extra sure that there were no hidden files lurking in there, and attempted to rm -rf it with the same result.

Eventually I tried zpool status -v which told me I had some checksum errors on the pool, including the directory I was trying to delete. Presumably my drive was failing and it just so happened that rather than a file getting some bad data, some directory metadata on the filesystem did, and zfs was now incapable of deleting said directory. zpool scrub wasn’t able to accomplish anything useful, so I verified that my backups of my important files were good and up-to-date, and ordered a replacement drive for the system.

I wasn’t looking forward to reinstalling and reconfiguring GhostBSD to my liking again so I decided to do a full backup of everything to an ISCSI target on my NAS for safe keeping. I formatted the target as ZFS, mounted it on my workstation and attempted a zfs send … | zfs receive … to move the data over, only to find out that the zfs send reliably died when it got to the unremovable directory. Ugh. I tried a few different things to get rid of the directory so I could back everything else up, I discovered that while I couldn’t rm it or mv it to another pool, I could mv the directory to another dataset on the same pool, so I ended up moving it out of the way, backing up the dataset it was on, then moving it back so I could backup the other pool, and eventually ended up with a copy of all my datasets on my backup pool.

I was relieved to see that zpool scrub and zpool status -v did not see any errors on the backup pool. I was a little concerned, not knowing enough about how zfs send worked, that sending a pool with corruption might send along the corrupt data structures with it, but it does not appear to do so.

During the next few days I continued to use my workstation while waiting for the replacement drive, and things mostly worked fine except for on one occasion where a large file I downloaded via ssh gave errors decompressing. After investigation I found the md5 has was wrong on my downloaded copy and that zpool status -v was once again complaining about this file. Luckily erasing it and redownloading it resolved the issue. A few days later I had everything re-installed on a shiny new 1TB SSD.

I’m kind of disgruntled that ZFS wouldn’t provide any mechanism to fix corruption in its on-disk representation of a directory, to at least let me remove the data and back up the pool. Far inferior filesystems have repair tools to at least let you peacefully lose the data it can’t recover (I should know I’ve unfortunately had to use them many, many times), so for ZFS to just throw up its hands and shrug is kind of disconcerting. On the other hand, I was able to work around the issue and get everything backed up in the end, so no harm done, and I’m pretty sure all the checksumming that ZFS does helped me notice the drive was going much earlier than normal and save all my data. So, thanks?

Trying the Skype Web Client on GhostBSD

15 December 2020

A couple of months ago, I wrote about my experiences with running the Linux Skype Client in a Debian VM under FreeBSD.

In summary I have everything working pretty well for my uses, with one main problem– since I run Skype on a VM and forward the GUI via X11, I’ve never managed to be able to share my screen with whomever I’m talking to. My workaround has been to have them share there screen and walk them through whatever it is I want to show them. Its not something that comes up more than once every few weeks at $WORK, but it is an annoyance that I’ve been looking to resolve. I’m thinking that If I installed a full X11 system in my Debian VM and used the desktop inside the VirtualBox window, I’d at least be able to share that screen and open a terminal or whatever there to share. I’ve not been ready to try that route yet though, I prefer just having a light command line VM and forwarding my applications to my host’s X11 via ssh as opposed to a ‘desktop in a window’ VM.

One of the first things I had tried a year ago was to use the Skype Web Client. I had been unsuccessful originally but decided to give it another shot as I’ve seen others online claiming it works for them. Chromium was still a non starter. I’m able to log in but the ‘call’ button is grayed out with a mouse over tip informing me that audio and video calls are unsupported on my browser. I downloaded a UserAgent switcher and pretended to be Chrome on Linux and even Chrome on Windows, but with no change. Based on my reading, I believe the issue is that Skype uses some codecs that are not included with the open source Chromium browser, but are only available in Chrome.

I next moved on to Firefox. Since Firefox isn’t supported by the Skype Web Client, I had to again download a UserAgent Switcher and pretend to be Chrome. This time I was actually able to log in and make a voice call. Previously when I tried this same thing, the audio quality was choppy to the point of being unusable, but this time I was able to successfully make a voice call and it sounded pretty good. I’m not sure if the difference is due changes in the software or operating system in the past year, or due to hardware (Last time I did this I was on FreeBSD 12.1 on a Thinkpad T450, now I’m on 12.2 on a Dell Desktop). In any case that much works now.

It was with great anticipation that I attempted to share my screen, and I was excited when a dialog popped up showing me all my X11 windows and asking me whether I wanted to share my whole monitor, or just a window. It even had previews of my various windows, but alas, upon choosing to share my screen, nothing happened. The remote end never saw a screen appear, and on the sharing end, I couldn’t even tell it to ‘Stop Sharing’, it was like nothing ever happened. My guess is that the screen access API is a bit different in Chrome and Firefox, and making Skype think I’m Chrome for the benefit of letting me make calls, it also breaks the ability to Share screens. Too bad.

I wasn’t quite ready to give up yet though, I’d earlier read a thread on the FreeBSD forums about Running the Google Chrome Linux Binary on FreeBSD by using the Linuxulator Linux emulation layer. I had been under the impression that the Linux emulation in FreeBSD was outdated, only emulating a rather old Linux kernel, so this was something I’d never even considered in my quest for a usable Skype, but it appears some great strides have been made recently.

One evening I sat down and ran through the steps given in that thread for setting up an Ubuntu Linux environment and running Chrome in it. Despite the fact that I’m running GhostBSD, not vanilla FreeBSD, pretty much everything worked the same

  • The first gotcha I ran into was that the command ‘service linux start’ returned an error, but apparently it wasn’t needed– I planned to go back later and figure out the GhostBSD alternative once I’d run through the procedure, but after running the rest of the steps, it turns out nothing more was needed.

  • The second gotcha was that GhostBSD already had some file systems mounted under /compat/linux and even though I removed them from fstab and ran ‘mount -al’ as instructed, I was getting weird errors that based on the thread, other people also had when they didn’t have the mounts set up properly. I eventually figured out I needed to manually unmount, then run ‘mount -al’. I also needed to manually chmod /compat/linux/dev/shm for some reason, even though the permissions aready in the fstab.

  • Third, I find I need to manually run ‘mount -al’ and the chmod again after every boot, something isn’t starting up correctly on boot up, though I haven’t spend any time investigating what exactly I’m doing wrong

With those items out of the way, however, I was soon staring at a terminal full of ‘unsupported system calls’ and a seemingly functional Google Chrome Window. A quick visit to Youtube convinced me that sound was working and that everything seemed servicable, and it was off to web.skype.com I went.

I successfully logged into Skype and sent and received chat messages, but was not able to send or receive calls. If I called the BSD system, I just never got any incoming call. If I tried to make an outbound call It would try for a bit and then complain about a weak wifi signal, which is odd, since I’m on a wired ethernet with pretty good connectivity to the internet. I tried a bunch of stuff without much luck, and the suddenly, I managed to make a call and, after further fiddling with microphone settings, I had working bidirectional audio. Again, I gathered up my courage to try to share my screen and Success! This time I was able to share my screen and view it on the remote end. I hung up and tried again. Failure again. I tried again, same thing. And Again, and Again.

I had a few more successful call connections and many more failures. I tried to A/B it to figure out what made it work, but was unsuccessful. It seems random, but if I try a dozen times or so it seems to work eventually, so kinda success? I can’t rely on this to answer calls since it won’t reliably ring, so I’m sticking with my Skype client in my Debian VM for day-to-day usage, but I figure whenever I need to call a team mate for a pair debugging session or a show-and-tell , I’ll be able to login to the web client and spam the dialler a few times until a call goes through, so I’m at least in a better position than I was a week ago as far as screen sharing.

Now that I had the Linuxulator working, I did get the bright idea to try to run the Linux binary (non web) client in it, but no luck, it aborts early in the startup sequence, but it does appear that progress is being made with Linux emulation and who knows, maybe with FreeBSD 12.3, I’ll finally have this working.

Fun with 'du', symlinks, and bind mounts

12 December 2020

The du command estimates the amount of space taken up by a directory tree, I usually use it when I’m trying to figure out why something is taking up so much space, piped to a ‘sort -n’ to see what the largest subdirectories of a given start point are.

As a first approximation, du prints the directory tree under the starting point annotated with sizes, but that’s not exactly correct. Take the following example run on a Debian GNU/Linux box:

$ mkdir dir
$ ln -s dir link
$ touch dir/foo
$ du
4       ./dir
8       .

As you can see du did not follow the symlink, since this is the default behavior, unless the -L option is provided to make it dereference symlinks, as such:

$ du -L
4       ./dir
8       .

Hmm, ok that still didn’t work. It turns out that since the purpose of du is to determine how much space is used up by a directory tree, it tries really hard not to account for the same space twice, and realizes that the ./link directory has already been accounted for and skips it. In fact I ran this test a few times and was even to sometimes get it to skip the ./dir and process the ./link instead, probably something to do with inode number ordering I’m guessing.

Bind mounts are another alternative to symlinks in Linux that do sort of the same thing in a very different way and with different consequences. How does ‘du’ handle them?

$ mkdir mnt
$ sudo mount --bind dir mnt
$ du
4       ./dir
4       ./mnt
12      .

It appears that using a bind mount successfully tricks du into counting the space twice, but that’s not entirely true:

$ du -L
4       ./dir
8       .

The man page says that -L, “Dereferences all symbolic links”, but it appears that the man page is not telling the whole story. It appears that -L also turns on the “make sure we don’t count the same space twice” feature. Presumably without that option enabled, du assumes it doesn’t have to worry about such a situation and doesn’t run that code, allowing the bind mount to sneak in the back door.

You can leave off the -L option to tell du not to follow symlinks, but what if you don’t want to follow bind mounts? There is a convenient -x option which will “skip directories on different filesystems”, which sounds like it would help:

$ du -x
4       ./dir
4       ./mnt
12      .

But nope, the tool doesn’t see the bind mount as a separate filesystem, since its really part of the same filesystem mounted at a new point.

Unlike the Linux version of du, which is part of GNU Core Utils, the du from FreeBSD is a different program, originally from Version 1 AT&T Unix, and it does not appear to make this attempt to avoid double counting space. On FreeBSD all three directories are shown with the -L option is enabled, and the ./dir and the ./mnt when it is not enabled. (Using nullfs instead of bind mounts on FreeBSD, since it doesn’t support the latter by default)