I'll help you create a QuickShell bar with i3/Sway workspace integration and an elegant sliding tray. Here's a complete implementation:
// bar.qml
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
ShellRoot {
PanelWindow {
id: mainBar
anchors {
top: true
left: true
right: true
}
height: 30
color: "transparent"
Rectangle {
anchors.fill: parent
color: "#1a1b26"
RowLayout {
anchors.fill: parent
anchors.margins: 4
spacing: 10
// Workspaces
Row {
id: workspaceRow
spacing: 4
Repeater {
model: workspaceModel
Rectangle {
width: 30
height: 22
radius: 4
color: modelData.focused ? "#7aa2f7" :
modelData.visible ? "#414868" : "transparent"
border.color: modelData.urgent ? "#f7768e" : "transparent"
border.width: 2
Text {
anchors.centerIn: parent
text: modelData.name
color: modelData.focused ? "#1a1b26" : "#c0caf5"
font.pixelSize: 12
font.bold: modelData.focused
}
MouseArea {
anchors.fill: parent
onClicked: switchToWorkspace(modelData.name)
}
Behavior on color {
ColorAnimation { duration: 150 }
}
}
}
}
// Window Title
Text {
Layout.fillWidth: true
text: activeWindow
color: "#c0caf5"
font.pixelSize: 12
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
}
// System Tray Trigger
Rectangle {
id: trayTrigger
width: 80
height: 22
radius: 4
color: trayArea.containsMouse ? "#414868" : "transparent"
Row {
anchors.centerIn: parent
spacing: 4
Text {
text: "▼"
color: "#c0caf5"
font.pixelSize: 10
rotation: trayPanel.visible ? 180 : 0
Behavior on rotation {
NumberAnimation { duration: 200 }
}
}
Text {
text: "Tray"
color: "#c0caf5"
font.pixelSize: 12
}
}
MouseArea {
id: trayArea
anchors.fill: parent
hoverEnabled: true
onClicked: trayPanel.visible = !trayPanel.visible
}
Behavior on color {
ColorAnimation { duration: 150 }
}
}
}
}
}
// Sliding Tray Panel
PanelWindow {
id: trayPanel
visible: false
anchors {
top: mainBar.bottom
right: true
}
width: 200
height: trayContent.height
color: "transparent"
// Slide animation
property real targetY: mainBar.height
y: visible ? targetY : targetY - height
Behavior on y {
NumberAnimation {
duration: 250
easing.type: Easing.OutCubic
}
}
Rectangle {
id: trayContent
width: parent.width
height: trayLayout.height + 20
color: "#1a1b26"
border.color: "#414868"
border.width: 1
radius: 8
// Shadow effect
layer.enabled: true
layer.effect: DropShadow {
radius: 8
samples: 16
color: "#80000000"
verticalOffset: 2
}
ColumnLayout {
id: trayLayout
anchors {
top: parent.top
left: parent.left
right: parent.right
margins: 10
}
spacing: 8
// Tray items
Repeater {
model: trayModel
Rectangle {
Layout.fillWidth: true
height: 32
radius: 4
color: itemMouse.containsMouse ? "#414868" : "transparent"
RowLayout {
anchors.fill: parent
anchors.margins: 6
spacing: 8
// Icon placeholder
Rectangle {
width: 20
height: 20
radius: 4
color: "#7aa2f7"
Text {
anchors.centerIn: parent
text: modelData.icon
color: "#1a1b26"
font.pixelSize: 12
}
}
Text {
Layout.fillWidth: true
text: modelData.name
color: "#c0caf5"
font.pixelSize: 12
}
}
MouseArea {
id: itemMouse
anchors.fill: parent
hoverEnabled: true
onClicked: {
console.log("Clicked:", modelData.name)
if (modelData.action) modelData.action()
}
}
Behavior on color {
ColorAnimation { duration: 150 }
}
}
}
}
}
// Click outside to close
MouseArea {
anchors.fill: parent
z: -1
onClicked: trayPanel.visible = false
}
}
// Data models and IPC
property var workspaceModel: []
property string activeWindow: ""
property var trayModel: [
{ name: "Network", icon: "N", action: null },
{ name: "Volume", icon: "V", action: null },
{ name: "Battery", icon: "B", action: null },
{ name: "Settings", icon: "S", action: null }
]
// IPC with i3/sway
Process {
id: i3ipc
running: true
command: ["i3-msg", "-t", "subscribe", "-m", '["workspace", "window"]']
onStdout: data => {
updateWorkspaces()
updateActiveWindow()
}
}
Timer {
interval: 1000
running: true
repeat: true
onTriggered: {
updateWorkspaces()
updateActiveWindow()
}
}
function updateWorkspaces() {
Process.exec(["i3-msg", "-t", "get_workspaces"], (stdout) => {
try {
const workspaces = JSON.parse(stdout)
workspaceModel = workspaces.map(ws => ({
name: ws.name,
focused: ws.focused,
visible: ws.visible,
urgent: ws.urgent
}))
} catch (e) {
console.error("Failed to parse workspaces:", e)
}
})
}
function updateActiveWindow() {
Process.exec(["i3-msg", "-t", "get_tree"], (stdout) => {
try {
const tree = JSON.parse(stdout)
const focused = findFocusedWindow(tree)
activeWindow = focused ? focused.name : ""
} catch (e) {
console.error("Failed to parse window tree:", e)
}
})
}
function findFocusedWindow(node) {
if (node.focused && node.name) return node
if (node.nodes) {
for (const child of node.nodes) {
const result = findFocusedWindow(child)
if (result) return result
}
}
return null
}
function switchToWorkspace(name) {
Process.exec(["i3-msg", "workspace", name])
}
Component.onCompleted: {
updateWorkspaces()
updateActiveWindow()
}
}
For Sway compatibility, create a wrapper script:
#!/bin/bash
# sway-bar-wrapper.sh
# Detect if running under Sway or i3
if [ "$SWAYSOCK" ]; then
IPC_CMD="swaymsg"
else
IPC_CMD="i3-msg"
fi
# Export for QuickShell to use
export IPC_CMD
quickshell -c bar.qml
Then update the QML to use the environment variable:
// Add this property at the root level
property string ipcCommand: Environment.get("IPC_CMD") || "i3-msg"
// Update Process commands to use ipcCommand
Process.exec([ipcCommand, "-t", "get_workspaces"], ...)
Key features of this implementation:
- Workspace indicators - Shows all workspaces with different colors for focused, visible, and urgent states
- Smooth animations - Color transitions and sliding effects for the tray
- Elegant tray design - Slides down from the bar with a shadow effect and rounded corners
- Click outside to close - The tray automatically closes when clicking elsewhere
- Hover effects - Visual feedback on interactive elements
- Tokyo Night theme - Modern dark color scheme that looks professional
To extend this further, you could:
- Add actual system tray protocol support using StatusNotifierItem
- Implement real battery, network, and volume monitoring
- Add configuration options for colors and sizing
- Create custom animations for tray items appearing
- Add support for notification popups
The tray slides smoothly with an easing curve, and the arrow indicator rotates to show the open/closed state. The design is minimal but functional, perfect for a modern tiling window manager setup.