User Tools

Site Tools


Sidebar

software:sway

What is it?

sway is a tiling window manager, active project, working on Wayland. Just the right thing to try out for me after using Window Maker, which seems to stay on Xorg forever.

Running Sway on Fedora

  • Installation: dnf -y install sway
  • https://github.com/swaywm/sway recommends to run sway directly from the TTY. That means to set multi-user target as default target, login there, and run sway from there. You could also in ~/.bashrc check the terminal variables and start sway directly.
# I did a LXDE-desktop installation of Fedora
# removed default.target
rm -f /etc/systemd/system/default.target

# configured to system to run into multi-user by default
cd /etc/systemd/system
ln -s /usr/lib/systemd/system/multi-user.target default.target
reboot

# After this, I logged in as normal user at the terminal, and
# executed 'sway'.  Et voila, sway starts.

Configuration and first steps

After you got sway running, it's time to familiarize yourself with the keyboard shortcuts and modify the configuration. The default config can be seen at https://github.com/swaywm/sway/blob/master/config.in or in file /etc/sway/config . The config file teaches you all shortcuts you need at this moment.

On my thinkpad, the english keyboard layout was configured by default. The $mod-key is the windows-key, which is on Linux not used anyway. Sway uses that key heavily. For the start, you should use the config suggested by Sway, and can then adapt it to your needs.

Custom config file

The default config is /etc/sway/config. If you want to customize, do this:

mkdir ~/.config/sway
cp /etc/sway/config ~/.config/sway
vi ~/.config/sway

Terminal settings

By default, <modkey>+<return> starts an urxvt256c-ml terminal, my customization:

$ grep term ~/.config/sway/config
set $term /home/chris/bin/myterm.sh
$ cat /home/chris/bin/myterm.sh
xterm -en UTF-8 -fg white -bg black -fn \
  -Misc-Fixed-Medium-R-Normal--18-120-100-100-C-90-ISO10646-1 +sb -e bash

Alternatively, I try terminal 'terminator' now. The good points over xterm for me:

  • In xterm/wayland/sway, I did not get automatic url-selection to work. So triple-clicking string https://fluxcoil.net in xterm did not result in selecting that URL, but the whole line. I had that working with xterm/xorg, but the same configs fail for that purpose on xterm/wayland for me.
  • Increasing/decreasing the font is just great:
    • increasing: <crtl>+<shift>+<=> (makes sense, + is the second function of the =-key)
    • decreasing: <crtl>+<->
$ grep term ~/.config/sway/config
set $term /home/chris/bin/myterm.sh
$ cat /home/chris/bin/myterm.sh
terminator

Changing workspace

A workspace in Sway is what I called “virtual screen” in Window Maker. Regarding workspaces, I mostly go with the default config from Sway. I just added one detail: $mod+Left changes to the previous workspace, and $mod+Right to the next workspace. By default, one can with $mod+1 jump to the first workspace, with $mod+2 to the second workspace, and so on. So I added this in ~/.config/sway/config:

    bindsym Ctrl+Left workspace prev
    bindsym Ctrl+Right workspace next
    bindsym Hangul_Hanja+Left workspace prev
    bindsym Hangul_Hanja+Right workspace next

The last 2 lines are for the “right CTRL key” on this keyboard here which I bought in Korea. When running 'xev' and then pressing the key, one sees the identifier for the key, in my case 'Hangul_Hanja'.

Locking the screen

I have a habit of locking the screen when leaving the workplace, by pressing F9. Easy to implement:

# install xlock
dnf -y install xlockmore
# add the config
echo 'bindsym F9 exec /usr/bin/xlock -mode blank' >>~/.config/sway/config
# reload config
press <modkey> + <Shift> + <c>
press F9 for testing

Controlling brightness

On laptops, package `light` should be installed, and this be added to ~/.config/sway/config:

  bindsym $mod+F5 exec light -U 5
  bindsym $mod+F6 exec light -A 5

With this, one can press $mod+F5/F6 to control brightness.

Internal/external screens

Using xrandr is not recommended, but so far the replacements actually look good. I frequently dock/undock my system. When docked, I only want to use an external screen.

# lets look at the names for our outputs
swaymsg -t get_outputs
Output DP-4 'Dell Inc. DELL U2412M RPT5T2372ADL' (focused)
  Current mode: 1920x1200 @ 59.950001 Hz
  [..]
Output eDP-1 'Unknown 0x21ED 0x00000000'
  [..]

# In the sway config, I refer to these entries.  So I frequently
# modify the config, then reload with <modkey>+<Shift>+<c>, and 
# have the new setup active.

# in ~/.config/sway/config, for 'docked'config:
output DP-4 enable
output eDP-1 disable

# in ~/.config/sway/config, for all monitors active:
output DP-4 enable
output eDP-1 enable

Custom statusbar

dnf install -y python3-psutil fontawesome-fonts
cd /opt
git clone git://github.com/tobi-wan-kenobi/bumblebee-status

# now modify the users ~/.config/sway/config, change
status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done
into
status_command /opt/bumblebee-status/bumblebee-status \
  -m cpu memory battery time pasink pasource sensors2 \
  -p sensors2.showtemp=false sensors2.showcpu=false time.format="%H:%M" \
  -t powerline

Details: https://github.com/tobi-wan-kenobi/bumblebee-status

Japanese input: ibus

I did not get ibus/sway/wayland to run so far :( Apparently its because sway (a wayland window manager) uses a newer version of the wayland input protocol than ibus-wayland supports. Duck has details

dnf -y install ibus ibus-setup ibus-gtk3 ibus-wayland \
  ibus-skk ibus-mozc ibus-kkc ibus-qt
  
# run ibus-daemon at sway startup
echo 'exec /usr/bin/ibus-daemon --xim --daemonize' \
  >>~/.config/sway/config
  
# set environment variables, i.e. in ~/.bashrc
export IMSETTINGS_INTEGRATE_DESKTOP=yes
export IMSETTINGS_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export GTK_IM_MODULE=ibus

# then exit sway with <modkey>+<Shift>+<e>
# and start sway again, then
ibus-setup

# Once ibus-daemon is running, one is supposed to execute
/usr/libexec/ibus-wayland
# ..but this bails out with "No input_method global" currently.

Japanese input: fcitx

This works for me, but there is no fcitx-mozc package.

dnf -y fcitx fcitx-qt4 fcitx-qt5 fcitx-ui-light fcitx-anthy \
  fcitx-gtk3 fcitx-gtk2 fcitx-table-extra fcitx-table-other \
  fcitx-kkc fcitx-skk fcitx-configtool

# run fcitx at sway startup
echo 'exec fcitx -d' >>~/.config/sway/config

# set environment variables, i.e. in ~/.bashrc
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

# then exit sway with <modkey>+<Shift>+<e>
# and start sway again, then
imsettings-switch fcitx
fcitx-configtool

Hanging menu

I have experienced haning menus: so after pressing $mod + D, the menu for running applications stays and can not be removed. In that case, “killall dmenu” removed the menu, and $mod + Shift + c can reload the normal top bar.

Additional software

My reminder for additional software. All from Fedora or rpmfusion repos.

  • firefox, google-chrome
  • evince - pdf viewer
  • mplayer, qiv - video, picture viewer

TODO

  • I did not get ibus to run..
software/sway.txt · Last modified: 2019/11/11 06:05 by chris