Added notes for increasing number of audio vchannels under FreeBSD.
[website_subgeniuskitty.com] / data / notes / freebsd_11.md
CommitLineData
294e7375
AT
1# Overview #
2
3Installation notes for a FreeBSD 11 graphical workstation.
4
5
6# X11 & Fluxbox #
7
8Compile from ports:
9
10 x11/xorg
11 curl+libssh+smb
12 gmp+assembly_opts
13 mesa_libs+wayland
14 webp+x11
15 (xterm+xinerama)
16 x11/nvidia-driver
17 x11-wm/fluxbox
18
19Add the following line to `/etc/rc.conf`, rebooting or using `kldload` before
20attempting to start X.
21
22 kld_list="nvidia-modeset"
23
24Create the following configuration file at
25`/usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf`.
26
27 Section "Device"
28 Identifier "NVIDIA Card"
29 VendorName "NVIDIA Corporation"
30 Driver "nvidia"
31 EndSection
32
33Create `/home/ataylor/.xinitrc` to load Fluxbox and set
34resolution/orientation/etc.
35
36 xrandr --output HDMI-0 --mode 3840x2160 --pos 0x0 --output DVI-D-0 --rotate left --mode 2560x1600 --pos 3840x-150
37 /usr/local/bin/fluxbox
38
39After starting X, use the Fluxbox config menus to set:
40
41* Focus model = mouse focus
42* Auto-raise windows? = no
43* Style = Meta
44
45Overwrite `~/.fluxbox/keys` with my keys file:
46
47 # click on the desktop to get menus
48 OnDesktop Mouse1 :HideMenus
49 OnDesktop Mouse2 :WorkspaceMenu
50 OnDesktop Mouse3 :RootMenu
51
52 # scroll on the desktop to change workspaces
53 OnDesktop Mouse4 :PrevWorkspace
54 OnDesktop Mouse5 :NextWorkspace
55
56 # alt + left/right click to move/resize a window
57 OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
58 OnWindowBorder Move1 :StartMoving
59
60 OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner}
61 OnLeftGrip Move1 :StartResizing bottomleft
62 OnRightGrip Move1 :StartResizing bottomright
63
64 # control-click a window's titlebar and drag to attach windows
65 OnTitlebar Control Mouse1 :StartTabbing
66
67 # double click on the titlebar to shade
68 OnTitlebar Double Mouse1 :Shade
69
70 # left click on the titlebar to move the window
71 OnTitlebar Mouse1 :MacroCmd {Raise} {Focus} {ActivateTab}
72 OnTitlebar Move1 :StartMoving
73
74 # middle click on the titlebar to lower
75 OnTitlebar Mouse2 :Lower
76
77 # right click on the titlebar for a menu of options
78 OnTitlebar Mouse3 :WindowMenu
79
80 # open a terminal
81 Mod1 F1 :Exec xterm
82 # open a dialog to run programs
83 Mod1 F2 :Exec fbrun
84 # Open file manager
85 #Mod1 F3 :Exec spacefm
86 # current window commands
87 Mod1 F4 :Close
88
89 # Take a screenshot
90 111 :Exec /home/ataylor/bin/take_screenshot.sh
91
92 # Start screensaver, lock screen
93 110 :Exec xscreensaver-command -lock
94
95 # Window sizing commands
96 Control F1 :Minimize
97 Control F2 :Shade
98 Control F3 :Maximize
99 Control F4 :Fullscreen
100
101 Control F5 :MacroCmd {ResizeTo 1600 1250} {Moveto 0 0 UpperLeft}
102 Control F6 :MacroCmd {ResizeTo 1600 1250} {Moveto 0 0 LowerLeft}
103
104 Control F7 :MacroCmd {ResizeTo 1905 2160} {Moveto 0 0 UpperLeft}
105 Control F8 :MacroCmd {ResizeTo 1905 2160} {Moveto 0 0 UpperRight}
106
107 Control F9 :MacroCmd {ResizeTo 1920 1080} {Moveto 0 0 UpperLeft}
108 Control F10 :MacroCmd {ResizeTo 1920 1080} {Moveto 0 0 UpperRight}
109 Control F11 :MacroCmd {ResizeTo 1920 1080} {Moveto 0 0 LowerLeft}
110 Control F12 :MacroCmd {ResizeTo 1920 1080} {Moveto 0 0 LowerRight}
111
112Set the system clock by modifying `~/.fluxbox/init` to contain:
113
114 session.screen0.strftimeFormat: %a, %b %d %H:%M:%S
115
116# Ports - Misc #
117
118To enable searching ports via `make search key=text-string`, execute the
119following command.
120
121 cd /usr/ports && make index
122
123Some packages with auto-updating strings (like version number) fail checksum
124tests. Both `print/texinfo` and `security/trousers` are common examples. When
125encountering a message about size mismatches during the fetch stage, perform
126the following steps.
127
1281. Download the source file manually with `wget`.
1292. Use `make fetch-list` with `grep` to find out where the file should go.
130 Should be somewhere under `/usr/ports/distfiles`.
1313. Copy the file to the proper location.
1324. In the folder of the port you are trying to build, run `make makesum` to
133 update the checksum based on the currently present file.
1345. Resume making the port as normal.
135
136Compile and install the following ports:
137
138 sysutils/screen
139 ftp/wget
140 editors/vim
141 Set EDITOR=vim in ~/.profile
142 www/firefox
143 Build failing on ffmpeg dependency
144 going into ffmpeg folder and building directly solved it.
145 Also had to run (as root) dbus-uuidgen > /etc/machine-id
146 Otherwise firefox coredumps with:
147 "D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/etc/machine-id": No such file or directory"
148 mail/mutt
149 +sidebar
150 www/links (start with links -g)
151 sysutils/nitrogen
152 net/samba46
153 -ads,ad_dc,ldap
154 mount_smbfs -I 192.168.1.5 //ataylor@talisker/zfs_stripe_0 /mnt/zfs_stripe_0
155 graphics/geeqie
156 multimedia/vlc
157 +x264/x265 support
158 sysutils/fusefs-exfat
159 fuse_load="YES" -> /boot/loader.conf
160 /dev/nvd0s3 /mnt/windows exfat rw,mountprog=/usr/local/sbin/mount.exfat 0 0 -> /etc/fstab
161 devel/git
162 git config --global user.name "Aaron Taylor"
163 git config --global user.email "ataylor@subgeniuskitty.com"
164 devel/sdl20
165 graphics/ImageMagick-nox11
166 graphics/sdl2_image
167 net-p2p/deluge
168 irc/irssi
169 dns/bind-tools
170 www/apache24
171 apache24_enable="yes" -> rc.conf
172 in httpd.conf set:
173 ServerName
174 ServerAdmin
175 and uncomment the cgi (not cgid) module in the MPMPREFORK IFDEF
176 net-mgmt/icmpmonitor
177 emulators/simh
178 emulators/virtualbox-ose
179 Add "vboxdrv_load="YES"" to /boot/loader.conf
180 pw groupmod vboxusers -m ataylor
181 Add "vboxnet_enable="YES"" to /etc/rc.conf for bridging support
182 multimedia/quodlibet
183 devel/arm-none-eabi-gdb
184 devel/valgrind
185 devel/arm-none-eabi-gcc
186 editors/libreoffice
187 graphics/inkscape
188 graphics/okular
189 math/gnuplot
190 editors/texmaker
191 devel/openocd
192 Enable USB for non-root users:
193 pw groupmod operator -m ataylor
194 setup the devfs subsystem by adding these lines to the following files:
195 ***/etc/devfs.rules (FreeBSD >= 8):
196 [localrules=10]
197 add path 'ugen*' mode 0660 group operator
198 add path 'usb/*' mode 0660 group operator
199 add path 'usb' mode 0770 group operator
200 ***/etc/rc.conf:
201 devfs_system_ruleset="localrules"
202 graphics/gimp
203 -gutenprint (brings in samba-4.4 and conflicts with installed samba-4.6)
204 x11-fm/qtfm
205 x11-fm/twander
206 TODO: Re-work ~/.twander for FreeBSD
207 www/py-beautifulsoup
208 www/py-requests
209 www/py3-requests
210 games/linux-dwarffortress
211 games/openmw
212
213# Mounting SMB/CIFS at Boot #
214
215Add to `/etc/fstab`:
216
217 //ataylor@TALISKER/zfs_mirror_0 /mnt/zfs_mirror_0 smbfs rw,late,-N,-I192.168.1.5 0 0
218 //ataylor@TALISKER/zfs_stripe_0 /mnt/zfs_stripe_0 smbfs rw,late,-N,-I192.168.1.5 0 0
219
220Set ownership to `ataylor:ataylor` on `/mnt/zfs_stripe_0 and /mnt/zfs_mirror_0`
221since `mount_smbfs` uses default "owner and group IDs from the directory where
222the volume is mounted." (from `mount_smbfs` manpage)
223
224Add to `/etc/nsmbd.conf`
225 [TALISKER:ATAYLOR]
226 password=password-goes-here
227
228
229# Firefox Configuration #
230
231In `about:config`:
232
233 browser.newtabpage.enabled = false
234 general.useragent.override = NCSA Mosaic/1.0 (X11;SunOS 4.1.4 sun4m)
235 gfx.canvas.azure.backends = cairo
236 gfx.content.azure.backends = cairo
237 gfx.canvas.azure.accelerated = true
238
239Note that the `gfx.*` entries enable hardware acceleration since the Nvidia
240drivers I am using support cairo but not skia, or is it that cairo supports my
3ae69c39 241video drivers and skia doesn't?
294e7375
AT
242
243In preferences:
244
245* Remember last session on startup
246* Download files to `/home/ataylor/downloads`
247* Check for updates but do not auto-install
248* Default search -> DuckDuckGo
249* Do not provide search suggestions
250* Location Bar, disable all 'suggest' locations (History, Bookmarks, Open Tabs)
251
252Install plugins:
253
254
255* uBlock Origin
256* NoScript
257* Image Zoom
258* Save Image in Folder
259* Thumbnail Zoom Plus
260
261Execute `touch ~/.null` and then create `~/.config/user-dirs.dirs` as below.
262
263 XDG_DESKTOP_DIR="$HOME/.null"
264 XDG_DOWNLOAD_DIR="$HOME/.null"
265 XDG_TEMPLATES_DIR="$HOME/.null"
266 XDG_PUBLICSHARE_DIR="$HOME/.null"
267 XDG_DOCUMENTS_DIR="$HOME/.null"
268 XDG_MUSIC_DIR="$HOME/.null"
269 XDG_PICTURES_DIR="$HOME/.null"
270 XDG_VIDEOS_DIR="$HOME/.null"
271
272To make scrollbars move one-page-per-click rather than jumping to the cursor,
273create the file `~/.config/gtk-3.0/settings.ini` with contents:
274
275 [Settings]
276 gtk-primary-button-warps-slider=false
277
278
3ae69c39
AT
279# Audio Configuration #
280
281By default, FreeBSD only provides 16 virtual audio channels via `/dev/dsp`.
282Since Firefox appears to open a new connection for each tab that plays audio
283and does not release those connections as long as the tab remains open, I
284sometimes encounter error messages like the following.
285
286 mpv: can't open /dev/dsp!
287
288To verify the problem, use `fstat` to confirm that too many connections exist.
289
290 ataylor@lagavulin:~ % fstat | grep dsp
291 ataylor mpv 42458 27 /dev 215 crw-rw-rw- dsp0.15 w
292 ataylor mpv 36531 27 /dev 194 crw-rw-rw- dsp0.11 w
293 ataylor mpv 24332 25 /dev 204 crw-rw-rw- dsp0.13 w
294 ataylor firefox 61929 48 /dev 209 crw-rw-rw- dsp0.14 w
295 ataylor firefox 61718 23 /dev 259 crw-rw-rw- dsp0.22 w
296 ataylor firefox 61718 47 /dev 296 crw-rw-rw- dsp0.46 w
297 ataylor firefox 61718 51 /dev 273 crw-rw-rw- dsp0.30 w
298 ataylor firefox 61718 64 /dev 284 crw-rw-rw- dsp0.40 w
299 ataylor firefox 61718 68 /dev 245 crw-rw-rw- dsp0.17 w
300 ataylor firefox 61718 70 /dev 265 crw-rw-rw- dsp0.25 w
301 ataylor firefox 61718 73 /dev 280 crw-rw-rw- dsp0.36 w
302 ataylor firefox 61718 74 /dev 188 crw-rw-rw- dsp0.10 w
303 ataylor firefox 61718 75 /dev 278 crw-rw-rw- dsp0.34 w
304 ataylor firefox 61718 76 /dev 272 crw-rw-rw- dsp0.29 w
305 ataylor firefox 61718 79 /dev 282 crw-rw-rw- dsp0.38 w
306 ataylor firefox 61718 80 /dev 293 crw-rw-rw- dsp0.43 w
307 ataylor firefox 61695 47 /dev 264 crw-rw-rw- dsp0.24 w
308 ataylor firefox 61695 48 /dev 279 crw-rw-rw- dsp0.35 w
309 ataylor firefox 61695 66 /dev 274 crw-rw-rw- dsp0.31 w
310 ataylor firefox 61695 69 /dev 292 crw-rw-rw- dsp0.42 w
311 ataylor firefox 61620 17 /dev 247 crw-rw-rw- dsp0.18 w
312 ataylor firefox 61620 72 /dev 291 crw-rw-rw- dsp0.41 w
313 ataylor firefox 61208 17 /dev 254 crw-rw-rw- dsp0.20 w
314 ataylor firefox 61208 18 /dev 275 crw-rw-rw- dsp0.32 w
315 ataylor firefox 61208 48 /dev 201 crw-rw-rw- dsp0.12 w
316 ataylor firefox 59654 45 /dev 276 crw-rw-rw- dsp0.33 w
317 ataylor firefox 59654 70 /dev 295 crw-rw-rw- dsp0.45 w
318 ataylor python2.7 82359 20 /dev 145 crw-rw-rw- dsp0.16 w
319
320Before proceeding, ensure that no processes have `/dev/dsp` open. IOW, the
321above `fstat` list should be empty.
322
323With nothing using the audio device, increase the number of virtual channels
324with `sysctl`.
325
326 root@lagavulin:~ % sysctl -a | grep vchans
327 hw.snd.maxautovchans: 16
328 dev.pcm.2.play.vchans: 1
329 dev.pcm.1.play.vchans: 1
330 dev.pcm.0.rec.vchans: 4
331 dev.pcm.0.play.vchans: 16
332
333 root@lagavulin:~ # sysctl dev.pcm.0.play.vchans=256
334 dev.pcm.0.play.vchans: 16 -> 256
335
336 root@lagavulin:~ # sysctl hw.snd.maxautovchans=256
337 hw.snd.maxautovchans: 16 -> 256
338
339Add the following two lines to `/etc/sysctl.conf` so the change persists.
340
341 dev.pcm.0.play.vchans=256
342 hw.snd.maxautovchans=256
343
344
294e7375
AT
345# X11 Configuration #
346
347In `~/.Xresources`:
348
349 xterm*faceName: Liberaqtion Mono:size=12:antialias=true
350 xterm*font: 7x13
351
352In `~/.Xmodmap`:
353
354 !
355 ! Swap Caps_Lock and Control_L
356 !
357 remove Lock = Caps_Lock
358 remove Control = Control_L
359 keycode 9 = Caps_Lock NoSymbol Caps_Lock
360 keycode 37 = Escape NoSymbol Escape
361 keycode 66 = Control_L NoSymbol Control_L
362 add Lock = Caps_Lock
363 add Control = Control_L
364
365In `~/.xinitrc`:
366
367 xrdb /home/ataylor/.Xresources
368 xmodmap /home/ataylor/.Xmodmap
369
370
371# FreeBSD Configuration #
372
373Add to `/etc/sysctl.conf`:
374
375 kern.corefile=/dev/null
376
377# Screensaver/Screenlock #
378
379Compile the `x11/xscreensaver` port and execute `xscreensaver-demo` to
380configure the screensaver.
381
382Add `xscreensaver -nosplash &` to `~/.xinitrc`.
383
384Add a line like the one below to `~/.fluxbox/keys`.
385
386 110 :Exec xscreensaver-command -lock
387
388
389# Wallpaper Configuration #
390
391Create `~/bin/wallpaper_rotation.sh` and add to `~/.xinitrc`.
392Remember to make it executable.
393
394 #!/usr/local/bin/python3
395 # This script creates a wallpaper slideshow.
396
397 ##### Configuration
398
399 # List of image source directories
400 # Each sublist is of the form:
401 # [monitor ID, absolute path to directory containing images for this monitor]
402 source_dir = [
403 [0,"/mnt/zfs_mirror_0/wallpaper/ratio_10_16"],
404 [1,"/mnt/zfs_mirror_0/wallpaper/ratio_16_9"]
405 ]
406
407 # This list will be populated during runtime.
408 # Each sublist is of the form:
409 # [monitor ID, absolute path to image file to display on this monitor]
410 current_wallpaper = [
411 [0,""],
412 [1,""]
413 ]
414
415 # Path to nitrogen configuration file
416 nitrogen_config = "/home/ataylor/.config/nitrogen/bg-saved.cfg"
417
418 ##### Dependencies
419
420 from subprocess import call
421 from os import listdir
422 from os.path import isfile, join
423 from random import choice
424 from time import sleep
425
426 ##### Source Code
427
428 def write_config():
429 config_file = open(nitrogen_config, 'w')
430 for monitor in current_wallpaper:
431 # Indenting the following triple-quoted text inserts leading whitespace in the
432 # nitrogen config file. However, nitrogen strips leading whitespace before
433 # processing its config file and the extra whitespace makes this Python script
434 # more readable.
435 template = """[xin_{monitor_n}]
436 file={wallpaper_file}
437 mode=0
438 bgcolor=#000000
439 """
440 context = {
441 "monitor_n":monitor[0],
442 "wallpaper_file":monitor[1]
443 }
444 config_file.write(template.format(**context))
445 config_file.close()
446
447 def refresh_wallpaper():
448 write_config()
449 call(["/usr/local/bin/nitrogen", "--restore"])
450
451 def get_rand_from_dir():
452 file_choices = [x for x in listdir(source_dir[current_monitor][1]) if isfile(join(source_dir[current_monitor][1], x))]
453 filename = choice(file_choices)
454 filename = join(source_dir[current_monitor][1], filename)
455 current_wallpaper[current_monitor][1] = filename
456
457 # Put something up on all monitors
458 for i in range(len(source_dir)):
459 current_monitor = i
460 get_rand_from_dir()
461 refresh_wallpaper()
462
463 # Eternal slideshow loop
464 while 1:
465 current_monitor = (current_monitor + 1) % len(source_dir)
466 get_rand_from_dir()
467 refresh_wallpaper()
468 sleep(10)
469
470
471# Vim Configuration #
472
473Create `~/.vimrc` as follows.
474
475 set nocompatible " be iMproved, required
476 filetype off " required
477
478 set number
479 syntax on
480 set tabstop=4
481 set expandtab
482 "set background=dark
483 "colorscheme solarized
484
485 "Folding
486 "http://vim.wikia.com/wiki/Folding_for_plain_text_files_based_on_indentation
487 "set foldmethod=expr
488 "set foldexpr=(getline(v:lnum)=~'^$')?-1:((indent(v:lnum)<indent(v:lnum+1))?('>'.indent(v:lnum+1)):indent(v:lnum))
489 "set foldtext=getline(v:foldstart)
490 "set fillchars=fold:\ "(there's a space after that \)
491 "highlight Folded ctermfg=DarkGreen ctermbg=Black
492 "set foldcolumn=6
493
494 " Color the 100th column.
495 set colorcolumn=100
496 highlight ColorColumn ctermbg = lightgray
497
498
499# Deluge Configuration #
500
501Follow instructions at <https://whatbox.ca/wiki/deluge>. Add check boxes in Connection Manager:
502
503* "Automatically connect to selected host on start-up"
504* "Do not show this dialog on start-up".
505
506
507# Personal Software #
508
509Compile and install `wallproc`. Requires the following dependencies from ports:
510
511 devel/sdl20
512 graphics/ImageMagick-nox11
513 graphics/sdl2_image
514
515
516# Printer Configuration #
517
518Create a spool directory:
519
520 mkdir -p /var/spool/lpd/lp
521 chown daemon:daemon /var/spool/lpd/lp
522 chmod 770 /var/spool/lpd/lp
523
524Add an entry to `/etc/printcap`.
525
526 # HP LaserJet, M's Office
527 lp:\
528 :lp=:rm=192.168.1.252:rp=raw:\
529 :sh:\
530 :mx#0:\
531 :sd=/var/spool/lpd/lp:\
532 :lf=/var/log/lpd-errs:
533
534Edit `/etc/rc.conf` to add the line `lpd_enable="YES"`.
535
536Note that plaintext files print in stairstep. See the link below if I want to
537fix this. Consider adding a smart filter to only apply this to text and pass PS
538straight through.
539
540<https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/printing-lpd.html#printing-lpd-filters-stairstep>
541
542# TODO #
543
544 After reboot:
545 Setup virtualbox and verify CAD software runs
546 Firefox:
547 Menus/tabs/etc use AA fonts but websites don't. Why not?
548 YES: wiki.archlinux.org
549 NO: reddit
550 https://forums.freebsd.org/threads/firefox-no-gpu-acceleration-since-50-0.59089/
551 Check Debian & FreeBSD install notes from previous desktop systems
552 Add lagavulin to tape backup schedule over network. Where to spool?
553 sysutils/bacula-client
554
555
556# temp notes from ports compiles #
557
558===================================================================================================================
559
560 Virtualbox USB Support
561 USB Support:
562 ============
563
564 For USB support your user needs to be in the operator group and needs read
565 and write permissions to the USB device.
566
567 % pw groupmod operator -m jerry
568
569 Add the following to /etc/devfs.rules (create if it doesn't exist):
570
571 [system=10]
572 add path 'usb/*' mode 0660 group operator
573
574 To load these new rule add the following to /etc/rc.conf:
575
576 devfs_system_ruleset="system"
577
578 Then restart devfs to load the new rules:
579
580 % /etc/rc.d/devfs restart
581
582===================================================================================================================
583
584 FreeBSD USB NOTE:
585 To allow an ordinary user to acces any of the the hotplug USB interface
586 add him/her to the operator group (pw groupmod operator -m username), then
587 setup the devfs subsystem by adding these lines to the following files:
588
589 ***/etc/devfs.rules (FreeBSD >= 8):
590 [localrules=10]
591 add path 'ugen*' mode 0660 group operator
592 add path 'usb/*' mode 0660 group operator
593 add path 'usb' mode 0770 group operator
594
595 ***/etc/devfs.rules (FreeBSD <= 7):
596 [localrules=10]
597 add path 'ugen*' mode 0660 group operator
598
599 ***/etc/rc.conf:
600 devfs_system_ruleset="localrules"