labwcでflameshot
labwcでスクリーンショットを撮るアプリとして、flameshotを入れて動作させるのにやや苦労したのでまとめておく
1. 環境
OSを最小構成でインストールして、labwcが起動できる状態まで持っていく
labwcコマンドで起動できるところまでイケれば問題ないが、ターミナルは起動可能な状態にしておく
2. 確認事項
以下の確認事項通りに進めれば大抵はうまくいく(はず)
私自身がFedora 44とArchしか試していないので、それ以外のディストリビューションだとさらなる確認事項があるかもしれないが…
2-1. 必要なパッケージ
xdg-desktop-portal、xdg-desktop-portal-gtk、xdg-desktop-portal-wlrが入っていること
2-2. サービス
以下のサービスが動いているか確認する
2-2-1. labwc-session.target
$ systemctl --user status labwc-session.target
ここはtargetなので、.targetまで必要
もしここで、labwc-session.targetのUnitが存在しない場合は、
~/.config/labwc/systemd/user/labwc-session.targetを作成し、以下の内容で記述
Fedora 44ではこのtargetがなかったため、自分で追加した
以下Fedora 44でやった作業
作業をしたのち、一旦再起動
$ mkdir -p ~/.config/systemd/user/labwc-session.target
$ vi ~/.config/systemd/user/labwc-session.target
[Unit]
Description=labwc session
Documentation=man:labwc(1) man:systemd.special(7)
BindsTo=graphical-session.target
Wants=graphical-session-pre.target
After=graphical-session-pre.target
サービスが起動していなければ起動させる
$ systemctl --user --no-block start labwc-session.target
2-2-2. graphical-session.target
2-2-1でlabwc-session.targetが起動していれば、起動するはずだが…
$ systemctl --user status graphical-session.target
で、labwc-sessionは起動しているのに、graphical-session.targetが起動していないケースには遭遇していない
もし、そういう機会があれば調査する
2-2-3. xdg-desktop-portal
起動していなければrestartする
$ systemctl --user status xdg-desktop-portal
$ systemctl --user restart xdg-desktop-portal
2-2-4. xdg-desktop-portal-gtk、xdg-desktop-portal-wlr
2-2-3のxdg-desktop-portalサービスが起動してれば起動しているはずだが、もし起動していなければrestart
$ systemctl --user status xdg-desktop-portal-gtk
$ systemctl --user restart xdg-desktop-portal-gtk
$ systemctl --user status xdg-desktop-portal-wlr
$ systemctl --user restart xdg-desktop-portal-wlr
3. flameshotの起動
2の内容を実施したあとに、flameshotを起動
Fedoraの例
$ sudo dnf install flameshot
$ flameshot &
で、メニューバーなどにflameshotのアイコンが表示され、クリックでスクリーンショットモードに入ればOK
4. 自動起動
自動起動させたい場合は、~/.config/labwc/autostartに以下を記述
~
systemctl --user --no-block start labwc-session.target
systemctl --user --no-glock start xdg-desktop-portal
flameshot &
~
エラー処理まできちんとやらせたいのであれば、独自のシェルスクリプトを呼ぶようにする