sway - 共通事項 - タイトル取得


 クラウディア


1. 概要
2. 取得方法
3. 参考サイト

1. 概要

 「XWindow」であれば、プログラムのクラス名等は、「xprop」コマンドで取得できます。  「WayLand」では、「xprop」はどうさしないので「swaymsg」コマンドで取得します。

2. 取得方法

 ログインして、プログラムが動作している状態で。  端末を開いて。

swaymsg -t get_tree
 こんなん、出力されます。

#1: root "root"
  #2147483647: output "__i3"
    #2147483646: workspace "__i3_scratch"
  #3: output "VGA-1"
    #4: workspace "1"
      #7: floating_con "hogehoge@cachyos260124:~" (xdg_shell, pid: 13190, app_id: "foot", foreign_toplevel_id: "b9f7ea57d7d08bca3e14283a22ef740d")
      #6: floating_con "tint2" (xwayland, pid: 12613, instance: "tint2", class: "Tint2", X11 window: 0x400008, foreign_toplevel_id: "4b6facb02681edd18d65e7ce6bf23c89")
      #8: floating_con "~ : bash — Konsole" (xdg_shell, pid: 15057, app_id: "org.kde.konsole", foreign_toplevel_id: "af2c72119f7e8026ab4fa34a6b7645de")
 ちょっとこれだと、情報量が多くなることがあるので、パイプで「grep」コマンドに渡して、絞り込みます。  例えば、「tint2」の情報が知りたい場合は。

swaymsg -t get_tree | grep int2
 先頭の「t」を抜いているのがちょっとした工夫で、結果は、下記のようになります。

              "name": "tint2",
                "class": "Tint2",
                "instance": "tint2",
                "title": "tint2",

3. 参考サイト

 本ページは、「ChatGPT」軍曹を参考にさせていただきました。