Labwc Convenient Configuration

Recently, I used labwc to work, and gradually found some small problems, which are recorded here for the convenience of future generations.

At present, WeChat, DingTalk, Tencent Meeting, etc. used in mainland China cannot work under pure wayland, including chrome under pure wayland, and the candidate frame of Fcitx5 will go off track, so xwayland support must be enabled when compiling labwc.

Here are some personal solutions to common problems:

1. Taskbar

Where is the taskbar placed? If there are two screens, which screen will it be displayed on? Display icon or name, and what action to perform when clicked?

  • where to put it

    1"modules-center": [
    2    "wlr/taskbar"
    3    //"river/tags"
    4],
    

    wlr/taskbar is placed in "modules-center", that is, in the middle of the status bar

  • Single screen or dual screen output

    1// swaymsg -t get_outputs (sway)
    2// wlr-randr (others)
    3"output": "eDP-1",
    

    The value of output can be obtained from swaymsg -t get_outputs for sway, and can be obtained by running the wlr-randr command after installing wlr-randr. Separated by multiple commas (typeof: string|array), all asterisks, the default is all.

    I choose to output to the secondary screen. The main screen generally does not display the status bar, but only displays the core window, and the secondary screen is placed once. When you need to see auxiliary information such as the taskbar, just glance at it sideways.

  • taskbar configuration

    1"wlr/taskbar": {
    2  "all-outputs": true,
    3    "format": "{icon}",
    4    "on-click": "minimize-raise",
    5},
    

    all-outputs means that the software of all monitor windows will be collected and displayed, otherwise only the windows of this monitor will be displayed, which is somewhat inconvenient, depending on the preferences.

    format {icon} is to display the software icon, and it can also be set to display the software name, etc. You can view the corresponding document settings.

    on-click minimize-raise Click to display, and then click to retract.

Complete configuration file (https://github.com/kmephistoh/dotfiles/tree/main/.config/waybar/config):

  1{
  2  "layer": "top",
  3  "position": "bottom",
  4  // swaymsg -t get_outputs (sway)
  5  // wlr-randr (others)
  6  "output": "eDP-1",
  7  "modules-left": [
  8    //"wlr/taskbar",
  9    "custom/launcher",
 10    "cpu",
 11    "memory",
 12    "custom/media",
 13    "tray"
 14  ],
 15  "modules-center": [
 16    "wlr/taskbar"
 17    //"river/tags"
 18  ],
 19  "modules-right": [
 20    "custom/updates",
 21    "custom/wallpaper",
 22    "backlight",
 23    "pulseaudio",
 24    "clock",
 25    "battery",
 26    "custom/power"
 27  ],
 28  "pulseaudio": {
 29    "tooltip": false,
 30    "scroll-step": 5,
 31    "format": "{icon} {volume}%",
 32    "format-muted": "{icon} {volume}%",
 33    "on-click": "pactl set-sink-mute @DEFAULT_SINK@ toggle",
 34    "format-icons": {
 35      "default": ["", "", ""]
 36    }
 37  },
 38  "river/tags": {
 39    "num-tags": 6
 40  },
 41  "network": {
 42    "tooltip": false,
 43    "format-wifi": " {essid}",
 44    "format-ethernet": ""
 45  },
 46  "backlight": {
 47    "tooltip": false,
 48    "format": " {}%",
 49    "interval": 1,
 50    "on-scroll-up": "light -A 5",
 51    "on-scroll-down": "light -U 5"
 52  },
 53  "battery": {
 54    "states": {
 55      "good": 95,
 56      "warning": 30,
 57      "critical": 20
 58    },
 59    "format": "{icon} {capacity}%",
 60    "format-charging": " {capacity}%",
 61    "format-plugged": " {capacity}%",
 62    "format-alt": "{time} {icon}",
 63    "format-icons": ["", "", "", "", ""]
 64  },
 65  "tray": {
 66    "icon-size": 18,
 67    "spacing": 10
 68  },
 69  "clock": {
 70    "format": "{: %H:%M %d/%m/%Y}"
 71  },
 72  "cpu": {
 73    "interval": 15,
 74    "format": " {}%",
 75    "max-length": 10
 76  },
 77  "memory": {
 78    "interval": 30,
 79    "format": " {}%",
 80    "max-length": 10
 81  },
 82  "custom/media": {
 83    "interval": 30,
 84    "format": "{icon} {}",
 85    "return-type": "json",
 86    "max-length": 60,
 87    "format-icons": {
 88      "spotify": " ",
 89      "default": ""
 90    },
 91    "escape": true,
 92    "exec": "$HOME/.config/system_scripts/mediaplayer.py 2> /dev/null",
 93    "on-click": "playerctl play-pause"
 94  },
 95  "custom/launcher": {
 96    "format": " ",
 97    "on-click": "wofi -show drunk",
 98    "on-click-right": "killall wofi"
 99  },
100  "custom/power": {
101    "format": " ",
102    "on-click": "bash ~/.config/rofi/leave/leave.sh"
103  },
104  "custom/updates": {
105    "format": "{} Update(s)",
106    "exec": "checkupdates | wc -l",
107    "exec-if": "[[ $(checkupdates | wc -l) != 0 ]]",
108    "interval": 15,
109    "on-click": "alacritty -e paru -Syu && notify-send 'The system has been updated' "
110  },
111  "custom/wallpaper": {
112    "format": " ",
113    "on-click": "bash ~/.config/system_scripts/pkill_bc"
114  },
115  "wlr/taskbar": {
116    "all-outputs": true,
117    "format": "{icon}",
118    "on-click": "minimize-raise"
119  }
120}

2. Screen capture

There is a problem with flameshot taking screenshots under labwc. The response is abnormally delayed when drawing a range, but there is no problem when clicking start from the status bar. It is very strange and the state is unstable. You must find a replacement combination.

1     <keybind key="F9">
2       <action>
3         <name>Execute</name>
4         <command>sh -c 'grim -g "`slurp`" - | swappy -f -'</command>
5       </action>
6     </keybind>

The recommended combination is grim + slurp + swappy. After installation, configure the shortcut keys according to the above, and press F9 to select the range to take a screenshot. Please pay attention to the wording of the above action, directly <action name="Execute" command='grim -g "$(slurp)" - | wl-copy' /> will not work, I have stepped on the pit for the readers. For the reason, refer to the official [tips section] (https://labwc.github.io/tips-and-tricks.html).

grim for screenshots, slurp for range selection, swappy for post-editing.

swappy

Note that when swappy edits text, the logic is to select the range first, then type, and finally enter to confirm, and it is not possible to input Chinese (hand expression!), and there is no step instruction function of flameshot. So I keep both screen capture software, depending on the situation to choose.

3. Workspace settings

labwc-workspace

I used a release version a long time ago. Its terminal software can be called out and hidden by pressing F12. It is very considerate, because the terminal is UHF software in the Linux environment. When using it, press F12 to call out at any time. This function is available on many desktops. The environment is not so easy to set up. Most of the logic is that the shortcut key directly starts multiple instances, which obviously does not meet the usage requirements. Most people only need to open a terminal, and then switch with multiple tabs.

Under labwc, I can barely achieve similar functions through the function of workspace switching:

  • Add workspace first
 1   <desktops>
 2     <!--
 3       popupTime defaults to 1000 so could be left out.
 4       Set to 0 to completely disable the workspace OSD.
 5     -->
 6     <popupTime>1000</popupTime>
 7     <names>
 8       <name>work</name>
 9     </names>
10     <names>
11       <name>term</name>
12     </names>
13   </desktops>

I only set up two workspaces here, one work, the daily work environment; one term, a separate terminal environment. Next, set shortcut keys to switch between the two flexibly.

  • Set shortcut keys
 1     <keybind key="W-1">
 2       <action name="GoToDesktop" to="term" wrap="yes" />
 3     </keybind>
 4     <keybind key="C-W-1">
 5       <action name="SendToDesktop" to="term" follow="yes" wrap="yes" />
 6     </keybind>
 7     <keybind key="W-2">
 8       <action name="GoToDesktop" to="work" wrap="yes" />
 9     </keybind>
10     <keybind key="C-W-2">
11       <action name="SendToDesktop" to="work" follow="yes" wrap="yes" />
12     </keybind>

Explanation of the above configuration: win+1 switches to term, win+2 switches to work; ctl+win+1 puts the current active window in term, ctl+win+2 puts the current active window in work, so that the function similar to the switch of the boss key can be realized. The reader can decide how many workspaces to set up, and bind the shortcut keys he likes, which is very convenient to use.

The so-called boss key is to switch to the work interface that the boss likes with one key when fishing. I think you should understand! After all, life in the mainland is hard, and the Bodhisattva must be considerate.

Lastmod: Friday, February 23, 2024

See Also:

Translations: