Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about desktop

Schizo Desktop IV: Audio

I have an of­­fice. It's like a home of­­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­­fice but al­­so get to go out­­­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­­tu­al­­ly I have like 10, but I in­­ter­act with two. One is my per­­son­al desk­­top com­put­er, the oth­­er is my work lap­­top. and I want to use the same pe­­riph­er­als in the same way with both of them. That's why I have the world's most com­­pli­­cat­ed schizo desk­­top set­up.

This se­ries of posts will doc­u­­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­­nese gad­get­s.

Today: Audio

As in the rest of this se­ries, some­thing that usu­al­ly is very sim­ple be­comes a bit com­pli­cat­ed be­cause I want to use the same pe­riph­er­als with two com­put­er­s.

In the case of au­dio it's even worse be­cause I want to use dif­fer­ent de­vices de­pend­ing on con­tex­t.

The Requirements

  • I want to list­ed to both com­put­ers with­out head­set­s, be­cause I don't like wear­ing head­sets for long.
  • I want to be able to lis­ten us­ing head­sets if I want to, to take ad­van­tage of noise can­celling and to be qui­eter.
  • I have a good mi­cro­phone, I want to use. I don't want to use the bad ones, like my we­b­cam's, or my note­book's.

The Hardware

  • Speak­er: a lar­gish speak­er with a 3.5mm jack, hang­ing from the bot­tom of my desk, in­vis­i­ble.
  • Mi­cro­phone: a XLR con­denser mi­cro­phone (means it needs 48v phan­tom pow­er!)
  • Head­set: Blue­dio Hur­ri­cane H2 (with ca­ble!)

The head­set and mi­cro­phone switch com­put­ers as de­scribed in a pre­vi­ous post BUT how does a XLR mi­cro­phone con­nect to a com­put­er?

You need an au­dio in­ter­face. I have a su­per cheap chi­nese one:

The v8 live sound card

This plugs to a com­put­er via USB and works as a sound card, with in­put and out­put.

BUT it's not just a sound card, it's a mix­er. It has con­nec­tors for:

  • 2 Con­denser mi­cro­phones (yes, with phan­tom pow­er)
  • 2 "Ac­com­pa­ny" in­put­s, which are stereo line in­puts
  • Blue­tooth in­put
  • Mon­i­tor: this is a stereo out­put that is a mix of all in­put­s, so you can lis­ten to ev­ery­thing that's go­ing on.

It has vol­ume con­trols for "ac­com­pa­ny" / "mic" / "mon­i­tor" and a cou­ple nice LED feed­back light­s.

It al­so has a bunch of ef­fect­s, like re­ver­b, echo, sil­ly sound­s, etc. which I don't use.

That au­dio in­ter­face is the hub of my au­dio set­up. Usu­al­ly it's con­nect­ed to my work com­put­er with the mi­cro­phone, but I can switch it over to my per­son­al PC.

My per­son­al PC is con­nect­ed to it via BT, and the mon­i­tor out­put is con­nect­ed to the speak­er.

The head­set is a sep­a­rate usb de­vice for per­son­al pref­er­ence.

The Software

Not much need to do any­thing spe­cial with two ex­cep­tion­s:

  1. Dis­able all the au­dio in­ter­faces I don't want to ev­er use.
    • HD­­MI au­­dio out­­puts
    • We­b­­cam's mi­cro­­phone
    • Head­­set's mi­cro­­phone
  2. Use rofi-­sound-pick­er to choose where the sound goes. I use it most­ly to switch from speak­er to head­phones.

Rofi Sound Picker

The Routing

In work mod­e:

  • Both PCs sound via the au­dio in­ter­face and the speak­er con­nect­ed to its mon­i­tor out­put:
    • Per­­son­al PC via BT
    • Work PC via USB
  • Mi­cro­phone is con­nect­ed to the au­dio in­ter­face and is used by the work PC (and se­lect­ed in team­s/­zoom/etc as in­put)
  • Head­set is con­nect­ed to the work PC and I can change to it us­ing the rofi-­sound-pick­er

In Per­son­al mod­e:

The same as work mod­e, un­less I want to record some­thing, in which case I switch all the au­dio to the per­son­al PC and just pick and choose.

Conclusion

This is worth it even if all I got was both PCs com­ing out of the speak­er. The rest is good and a bonus.

Schizo Desktop III: Monitors

I have an of­fice. It's like a home of­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­fice but al­so get to go out­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­tu­al­ly I have like 10, but I in­ter­act with two. One is my per­son­al desk­top com­put­er, the oth­er is my work lap­top. and I want to use the same pe­riph­er­als in the same way with both of them. That's why I have the world's most com­pli­cat­ed schizo desk­top set­up.

This se­ries of posts will doc­u­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­nese gad­get­s.

Today: Monitors

I have at least three mon­i­tors for my two com­put­er­s. It can get more com­pli­cat­ed than that, but let's just lim­it this to the "ba­sic­s".

Be­cause one of the com­put­ers (my work one) is a note­book, it has its own mon­i­tor. Then I have two reg­u­lar mon­i­tors, both 1080p, one of them land­scape and the oth­er por­trait.

This is how that look­s.

The three monitors described above

This would nor­mal­ly be just a mat­ter of plug­ging them in the right com­put­er, but ... in my case there is no right com­put­er!

When I am work­ing, I want the mid­dle mon­i­tor to be con­nect­ed to my work lap­top, and when I am not, I want it con­nect­ed to my desk­top.

The right­most mon­i­tor I al­ways want for my desk­top (usu­al­ly play­ing mu­sic or videos while I work) and of course the lap­top keeps con­trol of its own screen.

Ad­di­tion­al­ly I want to be able to spo­rad­i­cal­ly con­nect ran­dom com­put­ers (like rasp­ber­ry pis) and have them show up on a mon­i­tor.

Now it's not so ob­vi­ous, right?

Enter The HDMI Matrix

This is a 4x2 HD­MI ma­trix. It has 4 in­puts and 2 out­put­s. That means it can get 4 dif­fer­ent video sig­nals and will route them to 2 dif­fer­ent mon­i­tors in a com­plete­ly ar­bi­trary man­ner.

  • Want in­put 1 in both out­put­s? Sure.
  • Want in­put 1 in mon­i­tor 1 and in­put 2 in mon­i­tor 2? Sure.
  • Want it the oth­er way around? Sure.

It's to­tal­ly over­pow­ered for what I need, which could be done with a sim­pler 4x1 switch, but hey, it's nice.

So, I have 4 in­puts con­nect­ed:

  1. My desk­top com­put­er
  2. My desk­top com­put­er
  3. My work lap­top
  4. A ca­ble that I can reach un­der the desk­top

The out­puts are con­nect­ed to the mid­dle and right­most mon­i­tors in the desk re­spec­tive­ly.

When I work, the con­fig­u­ra­tion is in­put 3 in the mid­dle mon­i­tor, in­put 1 in the right­most mon­i­tor.

When I am not work­ing, it's in­put 2 in the mid­dle mon­i­tor, in­put 1 in the right­most mon­i­tor.

When I have a rasp­ber­ry I want to look at for a mo­men­t, that's in­put 4 to the mid­dle mon­i­tor.

Of course there is an­oth­er prob­lem:

The por­trait mon­i­tor does­n't know it's on its side. So ev­ery­thing is ro­tat­ed 90 de­grees when shown there.

Enter AutoRandr

Au­toRan­dr is one of those tools once you have it and use it you can't live with­out it.

It saves the cur­rent mon­i­tor con­fig­u­ra­tion and can re­store it when­ev­er it sees the same mon­i­tors plugged in­to the same out­put­s.

So, just make it look nicein "work mode", and configure all the monitor rotations and so on, then autorandr --save work.

Then, when you are not working, make it look nice again, and autorandr --save home.

Have to do that in both com­put­er­s, of course.

From then on, when­ev­er the switch changes things around, au­toran­dr au­to­mat­i­cal­ly re­con­fig­ures the mon­i­tors the right way on both com­put­er­s.

The on­ly prob­lem is that to switch from home con­fig to work I would have to do things like "click on the B but­ton of the ma­trix thing un­til is says "3", then click on the A but­ton un­til it says "1" and it's bor­ing.

Enter the Remote

As you can see in the pre­vi­ous pic­ture, the ma­trix has a re­mote. It's a sim­ple re­mote, with 8 but­ton­s, one for each in­put/out­put com­bi­na­tion.

I could just use the re­mote to switch be­tween work and home con­fig­u­ra­tions, but that's bor­ing too.

So, I use soft­ware to drive an in­frared emit­ter that switch­es things around when I click a but­ton in the macro key­board or flip a switch on a web­page.

But that's for an­oth­er post.

Schizo Desktop II: Keyboard and Mouse

I have an of­fice. It's like a home of­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­fice but al­so get to go out­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­tu­al­ly I have like 10, but I in­ter­act with two. One is my per­son­al desk­top com­put­er, the oth­er is my work lap­top. and I want to use the same pe­riph­er­als in the same way with both of them. That's why I have the world's most com­pli­cat­ed schizo desk­top set­up.

This se­ries of posts will doc­u­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­nese gad­get­s.

Today: Keyboard and Mouse

I have 2 key­boards and no mouse. In­stead of a mouse I have a track­ball but for all prac­ti­cal pur­pos­es ... 1 mouse.

A keyboard, a mouse and a tiny keyboard

How do I use them with two computers?

The an­swer is Bar­ri­er which runs a serv­er in my per­son­al ma­chine and a client in my work lap­top.

With it run­ning, I can just slide my mouse to the edge of the screen of one com­put­er and it will ap­pear in the screen of the oth­er com­put­er. It's like mag­ic.

I can even copy­/­paste be­tween them trans­par­ent­ly, I just can't move win­dows across the fron­tier for ob­vi­ous rea­son­s.

How do I use them with random computers?

My key­board has 3 mod­es:

  • Wired (al­ways con­nect­ed to my per­son­al com­put­er)
  • Blue­tooth for up to 3 de­vices (not con­nect­ed to any­thing)
  • 2.4Ghz don­gle (not con­nect­ed to any­thing)

So, if I have a ran­dom com­put­er (say, a rasp­ber­ry pi I need to de­bug) I can just switch the key­board to use the 2.4Ghz don­gle, plug it in­to the com­put­er and use it that way.

What about the tiny keyboard?

That's macros. The wheel is vol­ume, and al­so con­trols my lights and oth­er things. The but­tons do things like con­trol my air con­di­tion­er.

It's a su­per cheap chi­nese one, and they have re­cent­ly be­come con­fig­urable in Lin­ux, which is al­ways nice.

Why a trackball?

Why not a track­bal­l?

Any special keyboard configuration?

Oh yes. because it's a 65% keyboard I have to choose between having an escape key or a ~ key.

So I chose both, and mapped escape to the caps lock key.

So when I start my ses­sion I run this:

# Map caps lock and esc to proper keys
xkeysnail --watch --devices "ROYUAN GamaKay 68" .config/xkeysnail/config.py &
sleep 1

setxkbmap -model pc104 -layout us -variant altgr-intl -option

The xkeysnail tool configures this keyboard (and only this keyboard) using this file:

from xkeysnail.transform import *

# define timeout for multipurpose_modmap
define_timeout(1)


# [Global modemap] Change modifier keys as in xmodmap
define_modmap({
    Key.CAPSLOCK: Key.ESC,
    Key.ESC: Key.GRAVE
})

So I get escape in the caps lock key, and ~ in the esc key.

Then setxkbmap configures a us international keyboard layout with the altgr-intl variant, which is the one I like.

Conclusions

This one is not very weird, oth­er than the re­liance in a sin­gle key­board and a track­bal­l. If you use mul­ti­ple com­put­ers in your set­up I rec­om­mend Bar­ri­er, it's a great tool.

Schizo Desktop I: USB switch

I have an of­fice. It's like a home of­fice but it's in an­oth­er place. It's just mine, so I get the peace and qui­et of a home of­fice but al­so get to go out­side to get there. It's a good set­up.

BUT I have two com­put­ers there. Well, ac­tu­al­ly I have like 10, but I in­ter­act with two. One is my per­son­al desk­top com­put­er, the oth­er is my work lap­top. and I want to use the same pe­riph­er­als in the same way with both of them. That's why I have the world's most com­pli­cat­ed schizo desk­top set­up.

This se­ries of posts will doc­u­ment it, the why and how of it, and the var­i­ous things I've learned along the way, along with mak­ing you want to buy weird chi­nese gad­get­s.

Today: My USB Switch

What is it? A 4x2 switch. That means you can con­nect 4 USB de­vices to it, and it can be con­nect­ed to 2 com­put­er­s.

It's not an ex­pen­sive de­vice, it costs around 6 dol­lars!

USB switch

How do you use it? It has a but­ton. When you click it, all the de­vices move from one com­put­er to the oth­er.

What's plugged in­to it? My we­b­cam, my mi­cro­phone (not re­al­ly, it's a bit more com­pli­cat­ed, but that's an­oth­er ar­ti­cle) and my head­phones.

The head­phones are ac­tu­al­ly con­nect­ed via a small USB au­dio card be­cause that gives me a vol­ume knob for them (a­gain, about 6 dol­lars).

USB audio card

Why these de­vices? Be­cause they are my "video cal­l" de­vices. If I am do­ing a video call for work, I use them from the work com­put­er, and when I want to do a per­son­al one, I use them from my per­son­al com­put­er.

They switch in about half a sec­ond, and they work fine.

I do not use this for key­board and mouse. I have oth­er, bet­ter so­lu­tions (a­gain, an­oth­er ar­ti­cle)

Phys­i­cal­ly how is it mount­ed? I at­tached to the bot­tom of the desk to my left, next to a hook for the head­set and the arm for the mi­cro­phone. When I want to switch, I just reach down and press the but­ton.

What can fail?

  • If you up­date the ker­nel in one of the ma­chines and did­n't re­boot then hot­plug­ging the USB de­vices may fail. Don't do that :-)
  • Some op­er­at­ing sys­tems or users may get con­fused by au­dio de­vices pop­ping in­to ex­is­tence and dis­ap­pear­ing.
  • If you for­get to switch noth­ing works and you will be the per­son in the video call say­ing "can you hear me?"

Color Coordination Using Base16

The Problem

A few days ago I wrote about how I moved from a al­l-in­clu­sive en­vi­ron­ment (KDE Plas­ma) to Qtile, a tiling win­dow man­ager, and all the things I did to have the ameni­ties I missed from Plas­ma.

One thing there that may need fur­ther ex­pla­na­tion is the sec­tion about col­or schemes be­cause the con­cepts them­selves are fair­ly un­usu­al.

So, let's dig in­to it a bit more.

This is how a few apps look by de­fault if you don't con­fig­ure things:

unconfigured apps

One is a Qt ap­p, and the oth­er is a GTK app and they look ... bad?

I mean, I don't re­al­ly care all that much, but not on­ly are the wid­get styles to­tal­ly dif­fer­en­t, but the col­ors are all over the place.

And the same hap­pens to Qtile's bar, and my ter­mi­nal (alacrit­ty) and my tmux­er (zel­li­j) and my web brows­er and so on.

Ev­ery­thing is a dif­fer­ent col­or.

In Plas­ma, a comon col­or scheme is en­forced on most apps (not in chrome, though) and it makes things much nicer.

So, what's the equiv­a­lent in the Win­dow Man­ag­er world? There is­n't one, re­al­ly, but there are bits and pieces you can make in­to ... 80% of it.

Here's what I did.

My Solution

First, you need a source of con­sis­tent col­or schemes. If you just re­al­ly, re­al­ly, re­al­ly like a sin­gle one, then they may have a site full of con­fig­u­ra­tions for dif­fer­ent apps to force them to fol­low it.

For ex­am­ple: Drac­u­la or Nord

But I want­ed to be able to try a bunch and see which one I liked.

For this, there is noth­ing like base16

Base16 de­fines a stan­dard. You will have 16 col­ors. Those col­ors mean things.

  • Col­or 0 is the back­ground.
  • Col­or 1 is the fore­ground.

And so on.

Then it de­fines some oth­er things, like "If you are do­ing a 'dark' scheme, col­ors go from dark­er to lighter" and so on.

Then they pro­vide a col­lec­tion of themes, which are each 16 col­ors fol­low­ing those rules.

For ex­am­ple, this is the Bro­gram­mer Theme:

scheme: "Brogrammer"
author: "Vik Ramanujam (http://github.com/piggyslasher)"
base00: "1f1f1f"
base01: "f81118"
base02: "2dc55e"
base03: "ecba0f"
base04: "2a84d2"
base05: "4e5ab7"
base06: "1081d6"
base07: "d6dbe5"
base08: "d6dbe5"
base09: "de352e"
base0A: "1dd361"
base0B: "f3bd09"
base0C: "1081d6"
base0D: "5350b9"
base0E: "0f7ddb"
base0F: "ffffff"

Now, sup­pose you want an app to fol­low the "base 16 stan­dard" to see how it looks in Bro­gram­mer style.

All you need to do is take that ap­p's con­fig file and put the right col­or where it needs it.

So, for ex­am­ple, for the Alacrit­ty ter­mi­nal:

colors:
  # Default colors
  primary:
    background: '0x1b1918'
    foreground: '0xa8a19f'

  # Colors the cursor will use if `custom_cursor_colors` is true
  cursor:
    text: '0x1b1918'
    cursor: '0xa8a19f'

  # Normal colors
  normal:
    black:   '0x1b1918'
    red:     '0xf22c40'
    green:   '0x7b9726'
    yellow:  '0xc38418'
    blue:    '0x407ee7'
    magenta: '0x6666ea'
    cyan:    '0x3d97b8'
    white:   '0xa8a19f'

Of course edit­ing all the con­fig files ev­ery time you want to change your col­or scheme is a pain.

So the base16 project al­so col­lects tem­plates. Those are files that when com­bined with a theme gen­er­ate the con­fig­u­ra­tion file for an ap­pli­ca­tion.

This is the Alacrit­ty tem­plate:

# Base16 {{scheme-name}} - alacritty color config
# {{scheme-author}}
colors:
  # Default colors
  primary:
    background: '0x{{base00-hex}}'
    foreground: '0x{{base05-hex}}'

  # Colors the cursor will use if `custom_cursor_colors` is true
  cursor:
    text: '0x{{base00-hex}}'
    cursor: '0x{{base05-hex}}'

  # Normal colors
  normal:
    black:   '0x{{base00-hex}}'
    red:     '0x{{base08-hex}}'
    green:   '0x{{base0B-hex}}'
    yellow:  '0x{{base0A-hex}}'
    blue:    '0x{{base0D-hex}}'
    magenta: '0x{{base0E-hex}}'
    cyan:    '0x{{base0C-hex}}'
    white:   '0x{{base05-hex}}'

See those bits like {{base05-hex}}? That one gets replaced with your theme's color 5.

But again, us­ing the tem­plate for each app you want to theme is bor­ing.

So you need a tool to do that. The one I use is called flavours

What flavours does is:

  • Get all the base16 col­or themes
  • Get all the base16 app con­fig tem­plates
  • Fol­low­ing a con­fig­u­ra­tion file, gen­er­ate all the con­fig files you need.
  • Op­tion­al­ly: run com­mands so the apps no­tice their con­figs have changed.

For ex­am­ple, this is my con­fig­u­ra­tion for Alacrit­ty:

[[items]]
file = "~/.config/alacritty/alacritty.yml"
template = "alacritty"
subtemplate = "default-256"
rewrite = false

It says:

  • Generate ~/.config/alacritty/alacritty.yml
  • Use the alacritty template
  • From that template use the version called default-256 (don't worry)
  • DO NOT RECRE­ATE THE WHOLE FILE

That last bit is im­por­tan­t. That file does­n't just have the the­me, it has a lot of oth­er im­por­tant stuff, so I don't want it to just have the theme in it.

So, I had to ed­it it once and put these lines be­fore and af­ter where the theme goes:

# Start flavours
... theme goes here
# End flavours

So when I use flavours to apply a theme it will only replace that bit and leave the rest.

Since alacritty notices when the config has changed, I don't need a hook entry. In other cases you can use it. Here's mine for qtile, to let it know it should reread its config:

hook = "killall -USR1 qtile"

So, I configured this for a bunch of things, and at this point, I can just run something like flavours apply atelier-forest and ...

color coordinated apps

Yeah, they are not per­fec­t. I still need to tweak some stuff, but it's get­ting there.

Cur­rent­ly my flavours con­fig­u­ra­tion co­or­di­nates the­se:

  • Alacrit­ty
  • Qtile
  • Zel­lij
  • Rofi
  • Qt
  • Gtk (us­ing Flat­col­or)
  • VS Code
  • Qute­Brows­er

That's rough­ly ev­ery app I use (yes, I am mi­grat­ing from Chrome to Qute­Brows­er for no good rea­son)

And be­cause I am not ok, I wrote a cou­ple of tiny things to make things eas­i­er for me.

A rofi-based theme pick­er called rofi-base16:

rofi-base16 in action

And a base 16 tem­plate for Zel­li­j.

I al­so wrote an ug­ly script to set VS Code's theme but it's shame­ful, so will not be shown here.

Hope­ful­ly this ex­plains some­thing to some­one. If it does­n't, well, it will help me when I in­evitably for­get how this works :-)


Contents © 2000-2024 Roberto Alsina