Commit 9a6b5125 authored by Murukesh Mohanan's avatar Murukesh Mohanan

new notes on alienware

parent 1102298f
......@@ -43,7 +43,7 @@ pagestyle: posts
{% endif %}
</section>
<div id="fb-root"></div>
<!-- <div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
......@@ -58,6 +58,8 @@ pagestyle: posts
data-numposts="10"
data-colorscheme="dark">
</div>
<noscript>Please enable JavaScript to view the comments powered by Facebook.</noscript>
-->
<!--
<div id="disqus_thread"></div>
<script type="text/javascript">
......@@ -74,5 +76,4 @@ pagestyle: posts
})();
</script>
-->
<noscript>Please enable JavaScript to view the comments powered by Facebook.</noscript>
</section>
......@@ -5,7 +5,7 @@ tags: [tech, linux]
---
It's been [4½ years since I bought my System76 laptop][sys76], and it is showing its
age. Back in 2013, an NVidia GT670 MX was a pretty decent laptop graphics card
age. Back in 2013, an NVIDIA GT670 MX was a pretty decent laptop graphics card
(which meant it couldn't hold a candle to the desktop graphics cards). But I was
able to play *Hitman: Absolution*, the various *Mass Effect* games, *Tomb
Raider* and so on on it, and with OK graphics levels and resolutions. Fast
......@@ -79,7 +79,7 @@ and processed it a bit to get this:
But that's probably the best bit about the Alienware UEFI setup. The UEFI menu
itself is … disappointing. It didn't support widescreen monitors, and I have
seen a few UEFI systems that do, so there's that. Many UEFI systems also support
screenshots, but this doesn't.
screenshots, but this one doesn't.
I needed to disable Secure Boot to get Arch to boot, as expected. Disabling
Secure Boot enabled legacy boot as well, and the legacy boot splash is somewhat
......@@ -197,7 +197,7 @@ command is long-winded enough that I saved it to file in root's home directory,
which turned out to be pretty handy later.
Next step was to edit `/etc/mkinitcpio.d/linux` to get it to create the
initramfs files in the locationss listed above directly (using [the mkinitcpio(2)
initramfs files in the locations listed above directly (using [the mkinitcpio(2)
method from the Arch Wiki][hook]).
Timezone set, `fstab` created, hostname set … and reboot!
......@@ -216,7 +216,7 @@ efibootmgr --disk /dev/nvme0n1 --part 1 --create --gpt --label "Arch Linux" --lo
Reboot again, and I'm dropped into a TTY. :disappointed: I had installed `gnome`
after all. Of course, I forgot that Arch doesn't automatically enable services,
so logging in, and `systemctl enable gdm; systemctl start gdm` later,
so logging in, and `systemctl enabla --now gdm` later,
I had … GDM crashing in a loop. I had both my TV and my monitor connected, so I
tried disconnecting my TV, which stabilized GNOME and allowed me to login.
Turns out GDM itself runs in Wayland, and while Wayland didn't have problems on
......@@ -285,11 +285,10 @@ My gaming will no longer be as frustrating as it was before. :sunglasses:
Who knew an Alienware would be so comfortable for Linux? Besides goof-ups I made
because I hadn't installed Arch in ages and didn't pay attention to the Wiki, it
was a pretty easy install. It would hvae been easier still if I'd gone for
was a pretty easy install. It would have been easier still if I'd gone for
Ubuntu, I suspect. A far cry from some of the laptops I have installed Linux on
for friends, maybe the year of the Linux desktop is indeed at hand.
<!-- section -->
[^1]: Not because of battery issues, but because I burnt(!) the LVDS cable
......
---
layout: post
title: Arch on Alienware - scratching itches
tags: [tech, linux]
---
So, it's been [half a year since][alien] I got the Alienware Aurora R7, and I
have had my fair share of bugs and annoyances. Today, I'll talk about a few of
those.
<aside markdown="1">
> Every good work of software starts by scratching a developer's personal itch.
[*The Cathedral and the Bazaar*][esr], Eric S. Raymond.
</aside>
<!-- section -->
# Shutting down
The Alienware series apparently has a fairly common issue of panicking on
shutdown ([1], [2], [3], [4], [5]). The apparent cause is something in the I2C
Designware module. The solution used to be [disabling it][21], but things have
changed since then, and now the Arch Linux kernel has it baked in instead of as
a module that could be blacklisted. With some help from [the Unix & Linux Stack
Exchange][unix], that problem has been overcome. The solution is to blacklist a
kernel function, as Stephen Kitt suggested in February, and the correct function
was identified by Yurij Mikhalevich right around the end of May.
So, to fix the panic issue, I needed to add the following to the kernel boot
parameters:
initcall_blacklist=dw_i2c_init_driver
In the intervening months, I had my own hack around this: while trying to figure
out when exactly the offending driver was loaded, noticed that shutting down
worked fine if I booted directly to the systemd `poweroff.target`. So I added
an additional EFI boot entry, which started the kernel with
`systemd.unit=poweroff.target`, and then wrote a short script that enabled a
one-time boot to that entry and restarted. So shutting down took a while longer,
but worked fine as long as I called that script.
<!-- section -->
# Multi-monitor and audio
So my setup looks something like this[^1] &mdash; with a horrible mess of
cables connecting the whole lot:
```
+--------------------+
| Alien |
| | +--------+
+--------------------+ | |
| |
+-------------------+ | |
| | | |
| | +----+---+ |
| | +---+ |Speakers| |
| | | | +----+---+ |
| | | M | | |
| | | o | | |
| | | n | | |
| Table | | i | | TV |
| | | t | | |
| | | o | | |
| | | r | | |
| | | | +----+---+ |
| | +---+ |Speakers| |
| | +----+---+ |
| | | |
+-------------------+ | |
| |
| |
+--------+
```
So my monitor, a 24" BenQ, is visually below the 46" Sony TV. The monitor is
smaller, but much closer than the TV, so reading is far easier on it. As a
result, it is my primary display when using the PC. However, the speakers are
connected to the TV's audio out, since I also use the TV via a Chromecast, and in
the past via an HDMI switch that connected it to my laptop. So it makes sense
for whatever's using the TV to have its audio go via the speakers.
This is where the annoyance begins. Since both displays are connected via
HDMI[^2], both are available for sound output (and the monitor has a built-in
speaker). Since the monitor is the primary, sound is usually preferentially
routed through it, on both Windows and Linux (with PulseAudio). Windows does a
better job of remembering after I select the TV as the output once. However, on
Linux, every time I switch display configuration (from mirror to extend and
*vice versa*), which I do quite often depending on whether I am gaming (mirror)
or watching videos (extend), output is reset to the monitor. (Or worse, sometimes
it picks the PC's S/PDIF output, which has nothing connected to it at all!)
Worse still, the sound settings are not at all helpful here:
![Sound Settings](https://i.imgur.com/eri1Grj.png)
Quick: which would be the TV and which would be the monitor? :unamused:
<!-- section -->
Thus, I have two problems (and regex ain't one of them):
1. Quick switching between display arrangements (GNOME Shell doesn't have
anything built-in for that, as far as I know).
2. Ensuring that the TV is the sound source, no matter what the arrangement is.
I tried fiddling with `~/.config/monitors.xml`, but it seems that file isn't
watched for changes. So modifying that file doesn't help. I tried an extension
for GNOME Shell, but I quickly ran in to problem (2) above. So once I again, I
settled on writing up scripts. Setting arrangements is easy enough with
`xrandr`:
```sh
xrandr --output DP-1 --primary --below HDMI-0 # extend above
xrandr --output DP-1 --same-as HDMI-0 # mirror
```
Here, DP-1 is the monitor connected on the DisplayPort, and HDMI-0 is the TV on
(surprise, surprise!) HDMI. It's not difficult to see which is which:
```
% xrandr :(
Screen 0: minimum 8 x 8, current 1920 x 2160, maximum 32767 x 32767
HDMI-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1920x1080 60.00*+ 59.94 60.05 60.00
1440x480 60.05
1280x720 60.00 59.94
720x480 59.94
640x480 59.93
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 connected primary 1920x1080+0+1080 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+ 59.94 50.00 60.05 60.00 50.04
1680x1050 59.95
1600x900 60.00
1280x1024 75.02 60.02
1280x800 59.81
1280x720 60.00 59.94 50.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
HDMI-1-1 disconnected (normal left inverted right x axis y axis)
```
The (far newer) monitor has far more supported modes. So it's easy to parse them
out and see which is which:
```sh
% xrandr |
awk '/connected/{name=$1; next} name && /x/{count[name]++} END {for (i in count) print i, count[i]}'
HDMI-0 5
DP-1 11
```
<!-- section -->
## PulseAudio
The tricky part, however, was PulseAudio. I find it confusing. There's
[`pactl`][pactl] and [`pacmd`][pacmd]. There's all those configuration files,
`default.pa` and whatever else, written in a custom format, from what I can tell.
Sinks, sources, ports, cards, …! 'Tis enough to make one throw up their hands in
despair!
Also, looking at the `pamcd` and `pactl` outputs, it's obvious that trying to
parse that deeply-nested structure using regex is just asking for trouble.
However, PA doesn't have first-party libraries for accessing this data from
friendly languages like Python. There have been a few projects trying to expose
such an API, but they don't seem well-maintained or extensive in coverage.
Worse yet, even though the `pactl` manpage says:
pactl only exposes a subset of the available operations. For the
full set use the pacmd(1).
`pactl` actually seems to expose more information than `pacmd`. For example,
here's part of the output for `pactl list cards`:
```
Active Profile: output:hdmi-stereo-extra1
Ports:
hdmi-output-0: HDMI / DisplayPort (priority: 5900, latency offset: 0 usec, available)
Properties:
device.icon_name = "video-display"
device.product.name = "BenQ GW2480
"
Part of profile(s): output:hdmi-stereo
hdmi-output-1: HDMI / DisplayPort 2 (priority: 5800, latency offset: 0 usec, available)
Properties:
device.icon_name = "video-display"
device.product.name = "SONY TV
"
Part of profile(s): output:hdmi-stereo-extra1
```
The equivalent on `pacmd list-cards`:
```
ports:
hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "BenQ GW2480
"
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "SONY TV
"
```
Two things of note:
1. A human-grokkable name (the product name) is available[^3] from PulseAudio!
(Those are, in fact, what Windows shows!) Why TF doesn't the sound settings use
those?
2. `pacmd`, ostensibly the more "powerful" command, doesn't show the profile
associated with each port. It's probably hidden away in some other sub-command,
and I'd need to parse out the port name matching the product name and then go
hunting.
At any rate, getting the correct profile for the output I want to use is now
easy with `pactl`:
```sh
tv="SONY"
pactl list cards |
awk -v "tv=$tv" '$1 ~ /Name:/ {name = $2} /device.product.name/ && ($0 ~ tv) {p = 1} p && /Part of profile/ {print name, $NF; exit}'
```
This gives the card name and the profile name, then I can do:
```sh
tv="SONY"
read -r card profile < <(pactl list cards | awk -v "tv=$tv" '$1 ~ /Name:/ {name = $2} /device.product.name/ && ($0 ~ tv) {p = 1} p && /Part of profile/ {print name, $NF; exit}')
pacmd set-card-profile "$card" "$profile"
```
<!-- section -->
Now all I need to do is wrap these up in scripts, have the display arrangement
script set the sound output as well[^4], and use [this neat extension][tbse] to add
a couple of icons to my panel, and bam! A click is all I need to switch profiles
or fix sound if some bug caused the sound to go wandering around.
---
I think, all said and done, a better way would have been to use PA configuration
files to set a higher priority for the TV. But I can't be arsed to learn the
configuration language. So: `¯\_(ツ)_/¯` My scripts work and I postpone PA for a
time when I have far more free time.
<!-- section -->
[^1]: ASCII boxes thanks to <http://asciiflow.com/>!
[^2]: Well, one via DisplayPort (/HDMI adaptor) and the other by HDMI,
technically, but both interfaces can do audio out, so both show up in the
sound settings.
[^3]: What's with the traling newline and other whitsepace there, though?
[^4]: With a 2-second `sleep` in between, to give time for PA to settle after
display rearrangement.
[alien]: {% post_url 2017-12-12-alien %}
[esr]: http://www.catb.org/esr/writings/homesteading/cathedral-bazaar/ar01s02.html
[unix]: https://unix.stackexchange.com/q/423797/70524
[pactl]: http://manpages.ubuntu.com/manpages/bionic/man1/pactl.1.html
[pacmd]: http://manpages.ubuntu.com/manpages/bionic/man1/pacmd.1.html
[tbse]: https://extensions.gnome.org/extension/1154/top-bar-script-executor/
[1]: https://helloworldproject.blogspot.jp/2016/11/installing-ubuntu-1610-on-alienware.html
[2]: https://forum.manjaro.org/t/kernel-panic-at-shutdown/11054/6
[3]: https://askubuntu.com/q/1008685/158442
[4]: https://www.dell.com/community/Alienware-General/Alienware-Aurora-R6-Booting-Linux-on-PCIe-M-2/td-p/5520641/page/2
[5]: https://www.reddit.com/r/Dell/comments/7j38lr/dell_aurora_r6_linux_mint_and_shutdown_issues/
......@@ -23,9 +23,9 @@
}
#main ul li {
padding: 0.5em 0;
padding: 0.2em 0;
margin-left: 0.5em;
list-style-image: url("../images/not_sign.png");
list-style-image: url('/images/out.png');
}
#main li.no-marker {
......
images/out.png

174 Bytes

......@@ -4,33 +4,34 @@ pagestyle: cann-table
permalink: /resources/
description: General stuff
---
# Vim: `vimrc` and plugins [![gitlab]](https://git.cse.iitb.ac.in/murukesh/vimrc){:.git} [![github]](https://github.com/murukeshm/vimrc){:.git} {#vim}
Currently contains a nifty `vimrc`, and some plugins:
- [vim-plug](https://github.com/junegunn/vim-plug)
- [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim.git)
- [diffchar.vim](https://github.com/vim-scripts/diffchar.vim)
- [molokai](https://github.com/tomasr/molokai.git)
- [nerdtree](https://github.com/scrooloose/nerdtree.git)
- [supertab](https://github.com/ervandew/supertab)
- [syntastic](https://github.com/scrooloose/syntastic)
- [tabular](https://github.com/godlygeek/tabular.git)
- [tagbar](https://github.com/majutsushi/tagbar.git)
- [vim2hs](https://github.com/dag/vim2hs)
- [vim-airline](https://github.com/bling/vim-airline)
- [vim-fugitive](https://github.com/tpope/vim-fugitive.git)
- [vim-go](https://github.com/fatih/vim-go.git)
- [vim-markdown](https://github.com/gabrielelana/vim-markdown)
- [vim-surround](https://github.com/tpope/vim-surround.git)
- [vimtex](https://github.com/lervag/vimtex)
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe.git)
{: #plugins-list}
In addition, I'm writing my own plugin for using [Vim as a
`MANPAGER`](/2015/08/28/vim-for-man.html):
- [vim-manpager](https://github.com/murukesh/vim-manpager)
# Home: dotfiles, including `.vim` and plugins [![gitlab]](https://git.cse.iitb.ac.in/murukesh/home){:.git} [![github]](https://github.com/muru/home){:.git} {#vim}
Currently contains a nifty `.zshrc`, `vimrc`, and some plugins:
- zsh
- [fast-syntax-highlighting](https://github.com/dharma/fast-syntax-highlighting)
- vim
- [vim-plug](https://github.com/junegunn/vim-plug)
- [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim.git)
- [diffchar.vim](https://github.com/vim-scripts/diffchar.vim)
- [molokai](https://github.com/tomasr/molokai.git)
- [nerdtree](https://github.com/scrooloose/nerdtree.git)
- [supertab](https://github.com/ervandew/supertab)
- [syntastic](https://github.com/scrooloose/syntastic)
- [tabular](https://github.com/godlygeek/tabular.git)
- [tagbar](https://github.com/majutsushi/tagbar.git)
- [vim2hs](https://github.com/dag/vim2hs)
- [vim-airline](https://github.com/bling/vim-airline)
- [vim-fugitive](https://github.com/tpope/vim-fugitive.git)
- [vim-go](https://github.com/fatih/vim-go.git)
- [vim-markdown](https://github.com/gabrielelana/vim-markdown)
- [vim-surround](https://github.com/tpope/vim-surround.git)
- [vimtex](https://github.com/lervag/vimtex)
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe.git)
{: #plugins-list}
In addition, I wrote my own plugin for using [Vim as a
`MANPAGER`](/2015/08/28/vim-for-man.html): [vim-manpager](https://github.com/muru/vim-manpager).
Old plugins:
......@@ -42,7 +43,13 @@ Old plugins:
- [ctrlp.vim](https://github.com/kien/ctrlp.vim): superseded by `ctrlp/ctrlp.vim`
- [LaTeX-Box](https://github.com/LaTeX-Box-Team/LaTeX-Box.git): superseded by `vimtex`
Once cloned to `~/.vim`, do:
Setting up usually goes:
1. Clone to a folder, say `~/home` (recursively, so that the zsh plugin is pulled in)
2. Copy files from there: `cp ~/home/. ~/ -ar`
Once done:
vim -c PlugUpdate
......@@ -50,20 +57,20 @@ And optionally:
vim -c PlugUpgrade
**Bonus**: My dotfiles repo [![gitlab]](https://git.cse.iitb.ac.in/murukesh/home){:.git}
The `.vim` used to be in a separate repo, then I merged it into home.
<!-- section -->
# Some scripts {#scripts}
- [`curlwc.sh`](https://github.com/murukeshm/scripts/blob/master/curlwc.sh):
- [`curlwc.sh`](https://github.com/muru/scripts/blob/master/curlwc.sh):
This script uses [curl(1)](http://manpages.ubuntu.com/curl.1) to download the
target file in parts. Not very robust.
- [`mtcd.sh`](https://github.com/murukeshm/scripts/blob/master/mtcd.sh):
- [`mtcd.sh`](https://github.com/muru/scripts/blob/master/mtcd.sh):
This script mounts all arguments in directories within `~/cdrom` (as ISO9660
images), and also handles unmounting.
These and more can be found on my scripts repo. [![github]](https://github.com/murukeshm/scripts){:.git}
These and more can be found on my scripts repo. [![github]](https://github.com/muru/scripts){:.git}
<!-- section -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment