Destroyed Fully functional sway desktop with optional GNOME integration under Debian Ubuntu (markdown)

Drew DeVault 2019-09-08 23:32:08 -07:00
parent 6b66651568
commit ff580e5baf

@ -1,224 +0,0 @@
## Introduction
**Note**: These instructions are community maintained and are not supported by sway.
This page is intended to help you set up a fully-functional sway desktop environment integrated with GNOME under Debian 10/Ubuntu. Features that will be covered:
- Manual and automatic screen locking using `swayidle` and `swaylock`
- Working notifications with `mako`.
- Nice application launcher and exit menu using `fzf` and `kitty`
- Taking of screenshots, optionally selecting a region, using `grim` and `slurp`
- Volume control with multimedia keys
- Laptop screen brightness adjustment using `brightnessctl` and bound to keyboard keys
- Nice status bar using `Waybar`
- GNOME integration, so that you can run GNOME apps and use GNOME settings to manage the network.
These instruction were tested under Debian 10 (Buster), but should also work under Ubuntu with minimal modifications.
## Sway
To do a basic install of sway under Debian 10, follow the instructions on the page [Debian-10-(Buster)-Installation](./Debian-10-(Buster)-Installation). They should also work with minimal modifications under Ubuntu.
Then make a local copy of the default configuration, in order to customize it:
```
mkdir ~/.config/sway
cp /usr/local/etc/sway/config ~/.config/sway/config
```
## Screen locking
To configure manual and automatic screen locking, we'll be using Sway's own swaylock and swayidle. Install then both from source:
```
sudo apt install libpam0g-dev
# swaylock
cd ~/sway-src
git clone https://github.com/swaywm/swaylock.git
cd swaylock
git checkout 1.4
meson build
sudo ninja -C build install
# swayidle
cd ~/sway-src
git clone https://github.com/swaywm/swayidle.git
cd swayidle
git checkout 1.5
meson build
sudo ninja -C build install
```
Now edit `~/.config/sway/config` and add the following example settings to start swayidle with Sway, and so enable auto locking and monitor poweroff:
```
exec swayidle -w \
timeout 600 'swaylock -f -c 000000' \
timeout 300 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock -f -c 000000'
```
I find it easier to put it right after the `Variables` section. The arguments are quite self-explanatory.
You can also set a key combination to trigger a screen lock, like for example by adding this line to sway's config:
```
bindsym $mod+Shift+Alt+l exec swaylock -c 000000
```
## Notifications with mako
Mako is a lightweight Wayland notification daemon. Let's install it from source:
```
cd ~/sway-src
git clone https://github.com/emersion/mako.git
cd mako
git checkout v1.4
meson build
sudo ninja -C build install
```
If you want to customize mako:
```
mkdir ~/.config/mako
editor ~/.config/mako/config # or open with your gui editor
```
Here is an example configuration:
```
anchor=bottom-right
border-radius=5
default-timeout=10000
height=500
width=400
```
Now edit `~/.config/sway/config` and add the line `exec mako` somewhere, to start mako with sway.
## Application launcher and exit menu
We'll improvise an application launcher using `fzf` and the terminal emulator `kitty`, it'll look like this:
![](https://davidrios.github.io/configs/kitty-fzf-launcher.png)
We need the newest version of kitty for proper wayland support, so we'll install the binary release from their GitHub repository. Install them:
```
sudo apt install fzf curl xz-utils suckless-tools
sudo mkdir /opt/kitty
curl -L https://github.com/kovidgoyal/kitty/releases/download/v0.14.4/kitty-0.14.4-x86_64.txz | sudo tar xvJ -C /opt/kitty
sudo ln -s /opt/kitty/bin/kitty /usr/local/bin
```
Now configure a profile for the kitty+fzf launcher:
```
mkdir -p ~/.config/kitty
cat <<EOF >~/.config/kitty/fzf-launcher.config
font_family DejaVu Sans Mono
font_size 20
enable_audio_bell no
remember_window_size no
initial_window_width 50c
initial_window_height 10c
background_opacity 0.85
EOF
```
Then edit `~/.config/sway/config` and replace the line `set $menu dmenu_path | dmenu | xargs swaymsg exec --` with the following:
```
set $fzf_launcher kitty --config \"$HOME/.config/kitty/fzf-launcher.config\" --class fzf-launcher --detach
set $menu $fzf_launcher sh -c \"dmenu_path | fzf | xargs -r swaymsg exec\"
for_window [app_id="fzf-launcher"] focus, floating enabled, border pixel 1
```
This will setup a basic menu launcher that can be summoned with the default `$meta+d` key combination.
### Exit menu
This is how the exit menu will look:
![](https://davidrios.github.io/configs/kitty-fzf-exit-menu.png)
We'll use this simple script: <https://gist.github.com/davidrios/41d72ef3f97104400c353bab3b1b89ab>, like so:
```
cd /tmp
curl -L https://gist.githubusercontent.com/davidrios/41d72ef3f97104400c353bab3b1b89ab/raw/a305a9ef3e44bac370de5165eaabaf3ce53e207b/sway-exit | tee sway-exit
sudo cp sway-exit /usr/local/bin/
sudo chmod +x /usr/local/bin/sway-exit
```
Then edit `~/.config/sway/config` and replace the line:
```
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'
```
with:
```
bindsym $mod+Shift+e exec $fzf_launcher /usr/local/bin/sway-exit
```
Now the default `$mod+Shift+e` key combination will show a nice exit menu with Logout, Sleep, Reboot and Shutdown options.
## Taking screenshots
For this we'll use [grim](https://github.com/emersion/grim) and [slurp](https://github.com/emersion/slurp). Let's install them first:
```
sudo apt install libjpeg-dev
cd ~/sway-src
git clone https://github.com/emersion/grim.git
cd grim
git checkout v1.2.0
meson build
sudo ninja -C build install
cd ~/sway-src
git clone https://github.com/emersion/slurp.git
cd slurp
git checkout v1.2.0
meson build
sudo ninja -C build install
```
Now to set sway key bindings. In the example below, the `PrtScn` key save a screenshot of the whole desktop and `Alt+PrtScn` lets you select a region to capture. Add them to the sway config:
```
set $screenshot_file \"$HOME/Pictures/screenshot-$(date '+%Y-%m-%d_%H-%M-%S').png\"
bindsym Print exec grim -s1 $screenshot_file
bindsym Alt+Print exec (slurp | grim -g- -s1 $screenshot_file)
```
## Volume control with multimedia keys
Put these keybindings on your Sway config file:
```
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ $(printf "%s\n" 100 $(($(pacmd dump-volumes | grep -m1 Sink | grep -Po '\d+(?=%)' | head -n1) + 3)) | sort -g | head -n1)%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -3%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
```
## Screen brightness adjustment
Install brightnessctl:
```
sudo apt install brightnessctl
```
And put these keybindings on your Sway config file:
```
bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym XF86MonBrightnessUp exec brightnessctl set +5%
```