aboutsummaryrefslogtreecommitdiffstats
path: root/home/quickshell/bar/blocks/ActiveWorkspace.qml
blob: 7969212413e1158aacc63f48f4bfd518b237db9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import QtQuick
import QtQuick.Layouts
import Quickshell.Io
import Quickshell.Hyprland
import "../"

BarText {
  // text: {
  //   var str = activeWindowTitle
  //   return str.length > chopLength ? str.slice(0, chopLength) + '...' : str;
  // }

  property int chopLength
  property string activeWindowTitle

  Process {
    id: titleProc
    command: ["sh", "-c", "hyprctl activewindow | grep title: | sed 's/^[^:]*: //'"]
    running: true

    stdout: SplitParser {
      onRead: data => activeWindowTitle = data
    }
  }

  Component.onCompleted: {
    Hyprland.rawEvent.connect(hyprEvent)
  }

  function hyprEvent(e) {
    titleProc.running = true
  }
}