summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-10-30 11:52:21 +0300
committereug-vs <eugene@eug-vs.xyz>2022-10-30 11:52:21 +0300
commita63070c3047ac1900070388c452bfcfdc9b9ceb5 (patch)
tree207bb4c356ddec7bb40b1e8b4d5029074521293d
parent83abe9776187a5d4b9150bbb765c64cf56c1dd61 (diff)
downloadeug-vs-xyz-a63070c3047ac1900070388c452bfcfdc9b9ceb5.tar.gz
blog: multi-user setup is finally figured
-rw-r--r--src/blog/2022-10-30.md52
-rw-r--r--src/blog/index.md1
2 files changed, 53 insertions, 0 deletions
diff --git a/src/blog/2022-10-30.md b/src/blog/2022-10-30.md
new file mode 100644
index 0000000..30ddeaf
--- /dev/null
+++ b/src/blog/2022-10-30.md
@@ -0,0 +1,52 @@
+# Multi-user setup is finally figured
+Having multiple users for different purposes really helps you separate concerns and allows for better focus. One thing that makes Linux systems shine here is that you can run multiple X sessions (e.g desktops) at the same time, and switch between them seamlessly. Today I've figured the latest piece of this setup which was the Pipewire audio.
+
+## Why bother with multiple users
+If you are the only person accessing your device, you might think that creating more users is a crazy idea. But that's not true - there are a lot of use-cases for this.
+
+Here's mine: I work as a software engineer and on my spare time I work on side projects. And guess what - it really helps to keep these things separate! The obvious benefit of this is having different config files. Overall my job "identity" is kept entirely separate from my personal one - GPG & SSH keys, `.gitconfig`, `.npmrc`, Downloads directory, browser profile (it can be done within one user though) and even the wallpaper!
+
+Apart from this, both users don't have access to each others' files - because they don't need to! This has a nice side-effect - if anyone gains access to my machine, let's say I run some untrusted code as `eug-vs` and get hacked - another user will stay safe :lock: (unless there's privilege escalation which anyway means you are screwed).
+
+And last but not least - you get less distraction! If you are trying to focus on your work, there are a lot of things that can quickly grab your attention - personal notifications, emails, and that funny project you were working on last week. And as you might have guessed - this problem completely vanishes when using separate user - enabling the "full focus" mode.
+
+## Multiple X sessions
+What I've mentioned so far is a basic feature of any modern operating system. But Linux takes it a step further, allowing you to run multiple X sessions (e.g desktops) at the same time. Usually you log in right in the `TTY 1`, but then at any moment you can switch to say `TTY 2` (`CTRL + ALT + F2`) and do your stuff as another user, including running another X session. You can have up to 10 of those (bound to your `F` keys). This is a really underrated feature. You may take it even further and run different desktop environments or window managers - with their own per-user customizations.
+
+## Keeping some configs in sync
+I hope you already keep your `.dotfiles` in `git`, and if you are not, what are you waiting for?! I also suggest using `stow` (`app-admin/stow`) for managing your dotfiles. This way you can update dotfiles from personal profile, `push` it to the remote and then `pull` as another user.
+
+## Displaying current user in dwm status bar
+This is deadly simple with `whoami` command, here's my *block* from `dwmblocks`:
+```c
+ {" ", "whoami", 0, 0},
+```
+
+## Mixing audio from multiple users :sound:
+I run Gentoo with `openrc`, and according to wiki Pipewire is recommended to be started manually in your `.xinitrc` via `gentoo-pipewire-launcher` command. System-wide Pipewire seems to be either unsupported, or really hard to set up properly. This means that each user that runs `startx` will have his own Pipewire session. And the problem is - those sessions start fighting with each other for your audio device. In practice this means that you hear a piece of sound from one user, then a bit from the other, and so on.
+
+Luckily I found a fix - you should enable *TCP* support in `pipewire-pulse.conf` (requires `USE="sound-server" media-video/pipewire`):
+```bash
+pulse.properties = {
+ # the addresses this server listens on
+ server.address = [
+ "unix:native"
+
+ {
+ # Use TCP socket for multi-user audio
+ address = "tcp:4713"
+ # Important: permissions for clients
+ # If not allowed, remote clients might get "access denied"
+ # error when trying to e.g change volume
+ client.access = "allowed"
+ }
+ ]
+}
+```
+
+Now add this to your `.zshenv` (or whatever shell you use):
+```bash
+export PULSE_SERVER=tcp:127.0.0.1:4713 # Use TCP for multi-user audio
+```
+
+And there you are! Now your Pipewire listens on TCP port and allows for multiple client connections, giving your that seamless audio experience :fire:
diff --git a/src/blog/index.md b/src/blog/index.md
index c486fe7..50b00a7 100644
--- a/src/blog/index.md
+++ b/src/blog/index.md
@@ -4,6 +4,7 @@
### October
+- [Multi-user setup is finally figured](2022-10-30.md)
- [Tell your designer that you use Tailwind :tailwind:](2022-10-16.md)
### September