diff --git a/modules/bar/scripts/Apps.sh b/modules/bar/scripts/Apps.sh new file mode 100755 index 0000000..fe47fc4 --- /dev/null +++ b/modules/bar/scripts/Apps.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +ID="$1" + +if [[ -z "$ID" ]]; then + echo "Usage: $0 Number" + exit 1 +fi + +declare -A MAP=( + # Youtube + ["Grayjay"]="" + # Browser + ["Ablaze Floorp"]="" + ["LibreWolf"]="" + ["brave-browser"]="" + ["chromium"]="" + #E-Mail + ["Mozilla Thunderbird"]="󰇮" + # Terminals + ["kitty"]="" + ["Alacritty"]="" + # Videoplayer + ["VLC media player"]="󰕼" + ["mpv"]="" + ["ffplay"]="" + # Chats + ["Discord"]="" + ["Signal"]="󰭹" + # Coding + ["Visual Studio Code"]="" + ["VSCodium"]="" + # Password + ["org.keepassxc.KeePassXC"]="" + # Cloud + ["Nextcloud"]="󰅟" +) + +# APPS=$(hyprctl clients -j | jq -r ".[] | select(.workspace.id == $ID) | .initialTitle") + +mapfile -t APPS < <( + hyprctl clients -j | + jq -r ".[] | select(.workspace.id == $ID) | .initialTitle" +) + +mapfile -t APPS_CLASS < <( + hyprctl clients -j | + jq -r ".[] | select(.workspace.id == $ID) | .initialClass" +) + +for i in "${!APPS[@]}"; do + if [[ -n "${MAP["${APPS[$i]}"]}" ]]; then + APPS[$i]="${MAP["${APPS[$i]}"]}" + elif [[ -n "${MAP["${APPS_CLASS[$i]}"]}" ]]; then + APPS[$i]="${MAP["${APPS_CLASS[$i]}"]}" + else + APPS[$i]="${APPS_CLASS[$i]}|${APPS[$i]}" + fi +done + +# for app in "${APPS[@]}"; do +# echo "$app" +# done + +RESULT="$ID $(printf '%s ' "${APPS[@]}")" +RESULT=${RESULT% } # remove trailing space +echo "$RESULT" \ No newline at end of file diff --git a/modules/bar/widgets/Workspaces.qml b/modules/bar/widgets/Workspaces.qml index cb99016..1e2e8ce 100644 --- a/modules/bar/widgets/Workspaces.qml +++ b/modules/bar/widgets/Workspaces.qml @@ -1,6 +1,7 @@ import QtQuick import Quickshell import Quickshell.Hyprland +import Quickshell.Io import "../../../colors" Row { // Workspace Row @@ -49,6 +50,26 @@ Row { // Workspace Row font.pixelSize: 18 font.family: "Inter, sans-serif" } + + Process { + id: workspaceContent + command: ["sh", "-c", Quickshell.env("HOME") + "/.config/quickshell/modules/bar/scripts/Apps.sh " + modelData.id] + running: true + + stdout: StdioCollector { + onStreamFinished: { + workspaceNum.text = this.text + console.log("networkScript output:", this.text) + } + } + } + + Timer { + interval: 1000 + running: true + repeat: true + onTriggered: workspaceContent.running = true + } } }