266 lines
No EOL
9.7 KiB
Markdown
266 lines
No EOL
9.7 KiB
Markdown
sway compositor installation
|
||
https://wiki.garudalinux.org/en/sway-cheatsheet
|
||
|
||
Make sure to have these list of tools that are alternative of x11 ones
|
||
https://soyuka.me/make-screen-sharing-wayland-sway-work/
|
||
|
||
todo
|
||
- network stats on waybar
|
||
- sleep/power button
|
||
- wifi manager
|
||
|
||
|
||
- Installing packages
|
||
sudo pacman -S sway swaybg foot polkit
|
||
- Type `sway` after opening it with `Super + Enter`
|
||
- Fixing resolution
|
||
First copy the config of sway to config of user directroy
|
||
```bash
|
||
mkdir -p ~/.config/sway
|
||
cp /etc/sway/config ~/.config/sway/
|
||
$EDITOR ~/.config/sway/config
|
||
```
|
||
In order to get device name and other availableresolutions and info type
|
||
`swaymsg -t get_outputs`
|
||
Then enabling it with
|
||
`output HDMI-A-1 mode 1920x1080@60Hz`
|
||
|
||
|
||
### more shotcuts
|
||
for tabbed mode : mod+D
|
||
launcher : mod + d
|
||
to escape tabbed mode : mod + e
|
||
for fullscreen : mod+f
|
||
closing focused wndow : mod+shift+q
|
||
|
||
to make current window appear on top of others : mod+shift+space
|
||
and then switch between floating and tiling window : mod + space
|
||
to change size of floating window : mod + drag with right click (resize mode need to be enabled with win + r to move or resize)
|
||
- config files
|
||
main config file is in `/etc/sway` which can be copied to `~/.config` for customization
|
||
and to load this changed config
|
||
`swaymsg reload`
|
||
- to kill kde session use
|
||
`qdbus org.kde.ksmserver /KSMServer logout 0 0 0`
|
||
`loginctl terminate-session`
|
||
`qdbus org.kde.KWin /Session org.kde.KWin.Session.quit `
|
||
- about audio
|
||
`pavucontrol` is important for audio output and configuration
|
||
```sh
|
||
systemctl --user status pipewire
|
||
systemctl --user status pipewire-pulse
|
||
# Sometimes, you may also need:
|
||
systemctl --user status wireplumber
|
||
```
|
||
These are necessary for audio
|
||
for inspecting
|
||
```sh
|
||
pactl list short sinks
|
||
pactl list short sources
|
||
```
|
||
- configuting volume
|
||
```txt
|
||
# in config file
|
||
# Increase volume
|
||
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
|
||
|
||
# Decrease volume
|
||
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
|
||
|
||
# Mute/unmute volume
|
||
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
|
||
```
|
||
if using alsa then
|
||
```txt
|
||
# Increase volume
|
||
bindsym XF86AudioRaiseVolume exec amixer set Master 5%+
|
||
|
||
# Decrease volume
|
||
bindsym XF86AudioLowerVolume exec amixer set Master 5%-
|
||
|
||
# Mute/unmute volume
|
||
bindsym XF86AudioMute exec amixer set Master toggle
|
||
```
|
||
- waybar
|
||
it a tray at top which display stats like ram used, volume, brightness and all
|
||
download it with `yay -S waybar` and start waybar in terminal
|
||
Also install `ttf-font-awesome` for icons
|
||
- brighness(2 ways)
|
||
- install `light` then
|
||
```yaml
|
||
# Increase brightness
|
||
bindsym XF86MonBrightnessUp exec light -A 10
|
||
|
||
# Decrease brightness
|
||
bindsym XF86MonBrightnessDown exec light -U 10
|
||
```
|
||
or
|
||
- install `brightnessctl` then
|
||
```yaml
|
||
# Increase brightness
|
||
bindsym XF86MonBrightnessUp exec brightnessctl set +10%
|
||
|
||
# Decrease brightness
|
||
bindsym XF86MonBrightnessDown exec brightnessctl set 10%-
|
||
```
|
||
|
||
- Touchpad configurations
|
||
- Make sure `libinput` is installed
|
||
- list devices too see device name and find device name of touchpad
|
||
`libinput list-devices` eg : `1267:12448:ELAN0708:00_04F3:30A0_Touchpad`
|
||
if identifier property isnt there then use
|
||
`swaymsg -rt get_inputs`
|
||
- type this in config
|
||
```yaml
|
||
# input "your-device-name"
|
||
input "1267:12448:ELAN0708:00_04F3:30A0_Touchpad" {
|
||
# Enable natural (reverse) scrolling
|
||
natural_scroll enabled
|
||
|
||
# Enable tap to click
|
||
tap enabled
|
||
}
|
||
```
|
||
Instead of `input <DEVICE_IDENTIFIER>` this can can be used to `input type:touchpad`
|
||
|
||
|
||
**Clipboard manager**
|
||
- make sure wofi is installed and so is wl-clipboard is installed
|
||
- Create this script
|
||
```bash
|
||
#!/bin/bash
|
||
HISTFILE=~/.clipboard_history
|
||
|
||
# Check and create history file if it doesn't exist
|
||
if [ ! -f $HISTFILE ]; then
|
||
touch $HISTFILE
|
||
fi
|
||
|
||
# Append new clipboard items to the history
|
||
wl-paste -n | tee -a $HISTFILE
|
||
|
||
# Display history using wofi and copy the selection back
|
||
selection=$(sort -u $HISTFILE | wofi --show=dmenu)
|
||
[[ -n "$selection" ]] && echo -n "$selection" | wl-copy
|
||
```
|
||
- Bind this with key mod+d
|
||
`chmod +x ~/scripts/clipboard_history.sh`
|
||
- Alternatively use copyq
|
||
|
||
|
||
Screenshot
|
||
- Make sure grimshot and swappy is installed. This command is used to take screenshot
|
||
`grimshot save area - | swappy -f -`
|
||
or
|
||
`grim -g "$(slurp)" - | swappy -f -`
|
||
- Then add this in config
|
||
`bindsym $mod+p exec grimshot save area - | swappy -f -`
|
||
|
||
|
||
Network stats
|
||
- we need to setup a toolkit it involvfes making changes into config so copy its default config from `/etc/xdg/wayland` to `~/.config/wayland`
|
||
- In `config.jsonc`, make sure to have following in network module
|
||
```json
|
||
"network": {
|
||
// "interface": "wlp2*", // (Optional) To force the use of this interface
|
||
"format-wifi": "{essid} ({signalStrength}%) ",
|
||
"format-ethernet": "{ipaddr}/{cidr} ",
|
||
"tooltip-format": "{ifname} via {gwaddr} ",
|
||
"format-linked": "{ifname} (No IP) ",
|
||
"format-disconnected": "Disconnected ⚠",
|
||
"format-alt": "{ifname}: {ipaddr}/{cidr}",
|
||
//"format-alt": "{icon} {ifname}: {ipaddr}/{cidr}", // overridden by on-click below (click also toggles format/format-alt)
|
||
"tooltip-format": "{ifname}\t{ipaddr}/{cidr}\ngateway\t{gwaddr}",
|
||
"tooltip-format": "{ifname}\t{ipaddr}/{cidr}\ngateway\t{gwaddr}\n\t{essid}\n{icon} ⇣{bandwidthDownBytes} ⇡{bandwidthUpBytes}",
|
||
"interval" : 2
|
||
|
||
},
|
||
```
|
||
- then restart waybar
|
||
|
||
|
||
Automatic sleep
|
||
- main command for sleep is `systemctl suspend`
|
||
https://askubuntu.com/questions/885936/how-to-properly-suspend-via-command
|
||
- command for automatic sleep after interval of time
|
||
`swayidle -w timeout 10 'systemctl suspend'` this will start a daemon
|
||
means if left idle for 10s system will sleep
|
||
|
||
|
||
obs studio (screen recording)
|
||
https://www.reddit.com/r/swaywm/comments/w6gca6/comment/ihh86vj/
|
||
- install `v4l2loopback` and restart your system
|
||
- wf-recorder can also do screen recording
|
||
for specific section of screen use this?
|
||
`wf-recorder -a -g "$(slurp)" -f filename.mp4`
|
||
`-a` : audio flag
|
||
also use this to bind with any command for recording
|
||
`bindsym $mod+o exec wf-recorder -g "$(slurp)" -f ~/Downloads/wfRecorder/$(date +%Y-%m-%d_%H:%M:%S).mp4`
|
||
and to stop this use
|
||
`bindsym $mod+ctrl+o exec pkill -SIGINT wf-recorder`
|
||
or for not including mic and computer audio use this
|
||
`wf-recorder -g "$(slurp)" --audio=alsa_output.pci-0000_04_00.6.analog-stereo.monitor -f ~/Downloads/wfRecorder/$(date +%Y-%m-%d_%H:%M:%S).mp4`
|
||
audio sources can be listed by
|
||
`pactl list short sources`
|
||
|
||
- some portals like `xdg-desktop-portal-gtk` and `xdg-desktop-portal-wlr` is recommended to be installed
|
||
- with obs-studio in order to record potion of screen use alt too when resizing.
|
||
|
||
|
||
wifi applet
|
||
- install network-manager-applet for arch and use command `nm-applet` to start it in waybar
|
||
|
||
|
||
bluetooth setup
|
||
- first make sure to enable bluetooth service with `systemctl enable --now bluetooth.service`
|
||
- Then install blueman which is a gui took which needs to be open through launcher
|
||
|
||
|
||
**Complex keybinding support**
|
||
In Sway, you can define complex keybindings using the bindsym directive to combine multiple key presses, but creating a "chained" key sequence directly (like keya+keyb followed by keyc) requires a workaround because sway does not natively support multi-key sequences that wait for a subsequent keypress.
|
||
|
||
However, you can achieve similar functionality using the bindsym directives along with exec commands that track the state of a key press. Here's a basic approach:
|
||
|
||
Define a variable to keep track of your sequence. You can use swaymsg to set environment variables (though this gets tricky and might require additional scripting if you want to create a more complex state machine).
|
||
|
||
Use combinations of bindsym. Here’s an example of how you could set up your keybindings in Sway config:
|
||
```
|
||
# Reset sequence variable
|
||
set $sequence ""
|
||
|
||
# First key combination
|
||
bindsym --release $mod+a exec swaymsg set-option persistent_layout "set $sequence a"
|
||
bindsym --release $mod+b exec swaymsg set-option persistent_layout "set $sequence $sequence b"
|
||
bindsym --release $mod+c exec swaymsg set-option persistent_layout "set $sequence $sequence c"
|
||
|
||
# Action on sequence completion
|
||
bindsym --released $mod+c exec sh -c 'if [ "$$sequence" = "ab" ]; then <your-action>; fi; set $sequence ""'
|
||
```
|
||
This is a simplified illustration; you would need to adapt it to your environment and ensure that you have the proper way to reset the variable after executing your desired action.
|
||
|
||
Use a separate script for multi-key functionality (if necessary): Sometimes, handling this with a more robust solution such as a script might be easier. You could use a shell script to read key input and execute an action once a specific sequence is detected.
|
||
```
|
||
#!/bin/bash
|
||
|
||
# Sample script that waits for a sequence
|
||
case $1 in
|
||
"ab")
|
||
# Run your command here for keya + keyb
|
||
echo "Action triggered for a + b"
|
||
;;
|
||
"c")
|
||
if [ "$PREV_KEYS" == "ab" ]; then
|
||
# Run your command for a + b + c
|
||
echo "Action triggered for a + b + c"
|
||
fi
|
||
;;
|
||
esac
|
||
```
|
||
Make sure to include this script in your keybinding:
|
||
|
||
`bindsym --release $mod+a exec /path/to/your/script.sh "ab"`
|
||
`bindsym --release $mod+c exec /path/to/your/script.sh "c"`
|
||
|
||
Make sure to modify these samples to fit your specific needs. Managing sequences of keys can be complex, so a thorough understanding of how Sway handles input and executing external commands will help you create the solution that works best for you.
|
||
|
||
For the best practices and limitations, be sure to check the Sway documentation and community resources as well. |