Category: ubuntu

Change resolution from command line in Ubuntu 18.04’s Wayland

Wayland doesn’t allow applications to change resolution, and there’s no official utility to do that. There’s a third party display-config script, but it stopped working with latest changes in Mutter API. Here’s a short workaround until a better solution comes up:


set -xeu -o pipefail


function get_serial() {
  serial="$(gdbus call --session --dest org.gnome.Mutter.DisplayConfig \
  --object-path /org/gnome/Mutter/DisplayConfig \
  --method org.gnome.Mutter.DisplayConfig.GetResources | awk '{print $2}' | tr -d ',')"
  echo $serial

gdbus call --session --dest org.gnome.Mutter.DisplayConfig \
  --object-path /org/gnome/Mutter/DisplayConfig \
  --method org.gnome.Mutter.DisplayConfig.ApplyMonitorsConfig \
  $serial 1 "[(0, 0, $scale, 0, true, [('eDP-1', '$resolution', [] )] )]" "[]"

It should be called like this: [email protected] 1

Notice that you need to replace “eDP-1” with your monitor id. And you need to provide a supported resolution. You can get those by running dbus-monitor and changing resolution from GUI.

Typing diacritics Mac-style in Ubuntu 17.10

One can say many bad things about Mac OS, but what they got right for sure is typing diacritics, such as ñ or é. You don’t have to add layouts or switch languages, just use alt+n to get dead tilde and alt-e for dead acute accent.

But in Ubuntu, it’s not possible to type diacritics at all in default US layout. Instead, you have to switch in “U.S. international”, which has all the keys messed up – such as, apostrophe key is now dead acute. And to type an actual , you need to use ‘ + space. It’s almost as if user friendliness is a sin on Linux.

Fortunately, the process of adding a layout is well described in this question on SO. One difference is that Ubuntu 17.10 uses Wayland, which doesn’t have *.xkm, so no cache cleaning required. Just create symbols file, append to evdev.xml and then switch layout to get it working.

(Update: apparently Ubuntu 18.04 with Xorg also doesn’t have *.xkm files. But you might need to re-login for language entry to display correctly in the top bar).

$ cat /usr/share/X11/xkb/symbols/us_dia
default partial alphanumeric_keys
xkb_symbols "basic" {
  name[Group1]= "US English with diacritics that do not hate you (Mac style)";
  include "us(basic)"
  key  { [ n, N, dead_tilde ] }; //ñ, etc
  key  { [ e, E, dead_acute ] }; //é, etc
  key  { [ slash, question, U00BF ] }; // ¿ - Inverted Question Mark
  key  { [ 1, exclam, U00A1 ] }; // ¡ - Inverted Exclamation Mark
  key  { [ u, U, dead_diaeresis ] }; // ü, etc
  include "level3(lalt_switch)"

$ diff -u /usr/share/X11/xkb/rules/evdev.xml.2018-06-06 /usr/share/X11/xkb/rules/evdev.xml
--- /usr/share/X11/xkb/rules/evdev.xml.2018-06-06 2018-06-06 21:08:14.900404106 +0700
+++ /usr/share/X11/xkb/rules/evdev.xml 2018-06-08 16:06:16.927002821 +0700
@@ -1318,6 +1318,19 @@
+     <layout>
+       <configItem>
+         <name>us_dia</name>
+         <shortDescription>en</shortDescription>
+         <description>US English with diacritics that do not hate you (Mac style)</description>
+         <languageList>
+           <iso639Id>eng</iso639Id>
+         </languageList>
+       </configItem>
+       <variantList></variantList>
+     </layout>

Update 2: added inverted punctuation characters and diaeresis.