Let’s continue the Sway window manager (in Arch Linux) series I started in my previous post and continued in the other post.
Screenshots
We can use “grimshot”, part of sway-contrib, to take screenshots, which requires the main program for performing the actual screenshot, “grim”.
1 |
sudo pacman -S sway-contrib grim |
By default, such utilities are installed in “/usr/share/sway-contrib”, which is not part of the PATH. So, put that directory in the PATH environment variable or prefix the call with the full path.
Here’s the help of grimshot:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
$ /usr/share/sway-contrib/grimshot --help Usage: grimshot [--notify] [--cursor] [--wait N] (copy|save) [active|screen|output|area|window|anything] [FILE|-] grimshot check grimshot usage Commands: copy: Copy the screenshot data into the clipboard. save: Save the screenshot to a regular file or '-' to pipe to STDOUT. savecopy: Save the screenshot to a regular file and copy the data into the clipboard. check: Verify if required tools are installed and exit. usage: Show this message and exit. Targets: active: Currently active window. screen: All visible outputs. output: Currently active output. area: Manually select a region. window: Manually select a window. anything: Manually select an area, window, or output. |
You can try running that from the command line and do some experiments.
Then, you might want to set a few keybindings in the Sway config file, e.g.:
1 2 3 4 5 6 7 8 9 10 11 |
set $screenshot /usr/share/sway-contrib/grimshot ### Screenshot bindsym { # Capture the currently active output Print exec $screenshot --notify save output # Capture the currently active window Shift+Print exec $screenshot --notify save active # Select and capture a custom rectangular area Ctrl+Print exec $screenshot --notify save area } |
Let’s also install an image viewer, like “Eye of Gnome”:
1 |
sudo pacman -S eog |
This way, we can open the generated screenshot images.
Brightness and volume
How do you set the screen’s brightness and volume using the corresponding keys?
First, we need a program to control the brightness, “brightnessctl”. For the volume, we use “wpctl”, part of “wireplumber”:
1 |
sudo pacman -S brightnessctl wireplumber |
Here are the keybindings for the media keys for brightness and volume (if your keyboard has them):
1 2 3 4 5 6 |
### Brightness and Volume bindsym XF86MonBrightnessDown exec brightnessctl set 5%- bindsym XF86MonBrightnessUp exec brightnessctl set 5%+ bindsym XF86AudioRaiseVolume exec wpctl set-volume -l 1.0 @DEFAULT_SINK@ 5%+ bindsym XF86AudioLowerVolume exec wpctl set-volume -l 1.0 @DEFAULT_SINK@ 5%- bindsym XF86AudioMute exec wpctl set-mute @DEFAULT_SINK@ toggle |
Note the use of “-l 1.0” meaning that we don’t want to allow the wireplumber to increase the volume above 100%.
Running from a Display Manager
The default installation already created a file in the appropriate folder to let SDDM start the Sway session.
1 2 3 4 5 6 |
$ cat /usr/share/wayland-sessions/sway.desktop [Desktop Entry] Name=Sway Comment=An i3-compatible Wayland compositor Exec=sway Type=Application |
Let’s install the SDDM package:
1 |
sudo -S sddm |
Then, we enable the service at boot:
1 |
sudo systemctl enable sddm |
If we want to start it without rebooting, the first time we run:
1 |
sudo systemctl start sddm |
And now you can enter Sway from here.
Stay tuned for other posts on the Sway WM!