nicer globe

This commit is contained in:
ari committed 2026-10-27 13:30:14 -04:00
1 parent 0f42427f94
commit ee1d5a1170
7 files changed
+231 -46

No files matched your search

+13 -1
View File
@@ -60,6 +60,17 @@ You need these programs on your `PATH`:
| `curl` | Downloads remote app images when caching is on |
| `grim` | Takes window snapshots on Hyprland |
| `niri` or `hyprctl` | Provided by your compositor, used to read/move windows and workspaces |
| `qsb` | Compiles the workspace manager's shaders (from Qt Shader Tools) |
The workspace manager bends its cards onto the globe with a small shader.
Compile it once, and again whenever a file in `workspace-manager/shaders/`
changes. Without it the cards still show, just flat.
```sh
for shader in workspace-manager/shaders/*.vert workspace-manager/shaders/*.frag; do
qsb --glsl "100 es,120,150" --hlsl 50 --msl 12 -o "$shader.qsb" "$shader"
done
```
You can skip the Nushell CLI entirely and run the QML directly:
@@ -363,7 +374,8 @@ loop.
```
app-carousel/ # launcher: shell.qml, config, theme, cards
workspace-manager/ # overview: carousel, window search, window loop, compositor bridge
workspace-manager/ # overview: globe carousel, window search, window loop, compositor bridge
# shaders/ holds the card shader sources; .qsb files are built from them
workspace-badge/ # corner badge: name, color, rename and color editor
skygqts.nu # the `skygqts` CLI (Nushell)
package.nix # package definition
+13 -2
View File
@@ -2,6 +2,7 @@
lib,
stdenvNoCC,
makeWrapper,
qt6,
quickshell,
nushell,
curl,
@@ -22,9 +23,19 @@ stdenvNoCC.mkDerivation {
];
};
nativeBuildInputs = [ makeWrapper ];
nativeBuildInputs = [
makeWrapper
qt6.qtshadertools
];
dontBuild = true;
# Qt needs shaders compiled to .qsb before it can load them.
buildPhase = ''
runHook preBuild
for shader in workspace-manager/shaders/*.vert workspace-manager/shaders/*.frag; do
qsb --glsl "100 es,120,150" --hlsl 50 --msl 12 -o "$shader.qsb" "$shader"
done
runHook postBuild
'';
installPhase = ''
runHook preInstall
+123
View File
@@ -0,0 +1,123 @@
import QtQuick
// A workspace card bent onto the globe. The flat card is drawn into a
// picture, which a small shader wraps over the sphere. The flat card stays
// in place under it, hidden, so clicks still reach it. If the shader cannot
// be loaded, the flat card shows instead, tilted to face out of the globe.
// Fill the globe with this item; its middle is the middle of the globe.
Item {
id: root
required property Theme theme
// Where the card's middle sits on the globe, in radians. 0 is at the
// front, down and right are positive.
required property real lat
required property real lon
// Fade from the carousel steps. The fade toward the globe edge is added here.
required property real fade
required property string workspaceName
required property int workspaceIndex
required property bool selected
required property bool current
// Windows from parsed JSON, so this stays untyped.
required property var windows
signal activated
// 1 facing the viewer, 0 edge-on, below 0 on the back.
readonly property real facing: Math.cos(root.lat) * Math.cos(root.lon)
// Simple perspective: cards farther away get smaller.
readonly property real depthScale: root.theme.globeFocalLength / (root.theme.globeFocalLength + root.theme.globeRadius * (1 - root.facing))
// Fades out as it turns toward the edge of the globe.
readonly property real edgeFade: Math.max(0, Math.min(1, (root.facing - root.theme.globeHideFacing) / (root.theme.globeFadeFacing - root.theme.globeHideFacing)))
// The shader loaded, so the card is drawn bent.
readonly property bool warped: effect.status === ShaderEffect.Compiled
// The bent card picks this up from its parent, the flat one too.
opacity: root.fade * root.edgeFade
visible: root.facing > root.theme.globeHideFacing
WorkspaceCard {
id: card
theme: root.theme
workspaceName: root.workspaceName
workspaceIndex: root.workspaceIndex
selected: root.selected
current: root.current
windows: root.windows
x: root.width / 2 + root.theme.globeRadius * Math.cos(root.lat) * Math.sin(root.lon) * root.depthScale - card.width / 2
y: root.height / 2 + root.theme.globeRadius * Math.sin(root.lat) * root.depthScale - card.height / 2
scale: root.depthScale
// Only used when the shader is missing: lean back by the latitude,
// then turn by the longitude.
transform: [
Rotation {
origin.x: card.width / 2
origin.y: card.height / 2
axis {
x: 1
y: 0
z: 0
}
angle: root.warped ? 0 : -root.lat * 180 / Math.PI
},
Rotation {
origin.x: card.width / 2
origin.y: card.height / 2
axis {
x: 0
y: 1
z: 0
}
angle: root.warped ? 0 : -root.lon * 180 / Math.PI
}
]
onActivated: root.activated()
}
// The flat card as a picture, with room round it for the glow.
ShaderEffectSource {
id: picture
readonly property real margin: root.theme.globeCardMargin
sourceItem: card
sourceRect: Qt.rect(-picture.margin, -picture.margin, card.width + picture.margin * 2, card.height + picture.margin * 2)
hideSource: root.warped
smooth: true
mipmap: true
// Only the shader shows it.
width: 0
height: 0
}
ShaderEffect {
id: effect
// Read by the shaders, see shaders/globecard.vert.
property Item source: picture
property vector2d meshSize: Qt.vector2d(effect.width, effect.height)
property real sphereRadius: root.theme.globeRadius
property real focalLength: root.theme.globeFocalLength
property real lat: root.lat
property real lon: root.lon
// Centered on the middle of the globe. The shader moves each point
// to its place on the sphere from here.
x: (root.width - effect.width) / 2
y: (root.height - effect.height) / 2
width: picture.sourceRect.width
height: picture.sourceRect.height
visible: root.warped
mesh: GridMesh {
resolution: Qt.size(root.theme.globeCardMeshColumns, root.theme.globeCardMeshRows)
}
vertexShader: Qt.resolvedUrl("shaders/globecard.vert.qsb")
fragmentShader: Qt.resolvedUrl("shaders/globecard.frag.qsb")
}
}
+7 -43
View File
@@ -861,62 +861,26 @@ PanelWindow {
Repeater {
model: column.workspaces
WorkspaceCard {
GlobeCard {
id: card
required property var modelData
required property int index
// Place up or down the globe, in radians. Down is positive.
readonly property real lat: (card.index - column.latTurn) * root.theme.globeLatStep
// 1 facing the viewer, 0 edge-on, below 0 on the back.
readonly property real facing: Math.cos(card.lat) * Math.cos(column.lon)
// Simple perspective: cards farther away get smaller.
readonly property real depthScale: root.theme.globeFocalLength / (root.theme.globeFocalLength + root.theme.globeRadius * (1 - card.facing))
readonly property real stepFade: 1 - Math.min(Math.abs(card.index - column.latTurn) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
// Fades out as it turns toward the edge of the globe.
readonly property real edgeFade: Math.max(0, Math.min(1, (card.facing - root.theme.globeHideFacing) / (root.theme.globeFadeFacing - root.theme.globeHideFacing)))
anchors.fill: parent
z: card.facing
theme: root.theme
// Place up or down the globe, in radians. Down is positive.
lat: (card.index - column.latTurn) * root.theme.globeLatStep
lon: column.lon
fade: (1 - Math.min(Math.abs(card.index - column.latTurn) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)) * column.fade
workspaceName: modelData.name
workspaceIndex: modelData.idx
selected: column.isCurrentColumn && index === column.selectedWs
current: modelData.focused === true
windows: modelData.windows ?? []
x: column.width / 2 + root.theme.globeRadius * Math.cos(card.lat) * Math.sin(column.lon) * card.depthScale - card.width / 2
y: column.height / 2 + root.theme.globeRadius * Math.sin(card.lat) * card.depthScale - card.height / 2
z: card.facing
scale: card.depthScale
opacity: card.stepFade * column.fade * card.edgeFade
visible: card.facing > root.theme.globeHideFacing
enabled: !root.windowsOpen
// Lie flat on the globe: lean back by the
// latitude, then turn by the longitude.
transform: [
Rotation {
origin.x: card.width / 2
origin.y: card.height / 2
axis {
x: 1
y: 0
z: 0
}
angle: -card.lat * 180 / Math.PI
},
Rotation {
origin.x: card.width / 2
origin.y: card.height / 2
axis {
x: 0
y: 1
z: 0
}
angle: -column.lon * 180 / Math.PI
}
]
onActivated: root.activateAt(column.columnIndex, index)
}
}
+6
View File
@@ -186,6 +186,12 @@ QtObject {
// edge-on.
readonly property real globeFadeFacing: 0.6
readonly property real globeHideFacing: 0.2
// Cards are bent onto the globe by a shader. The bent picture keeps
// this much room round each card for its glow and shadow, and is cut
// into this many columns and rows. More means a smoother curve.
readonly property real globeCardMargin: 40
readonly property int globeCardMeshColumns: 16
readonly property int globeCardMeshRows: 12
// While the window loop is open, the globe moves so its middle sits at
// this share of the screen width, and shrinks and fades.
+23
View File
@@ -0,0 +1,23 @@
#version 440
// Draws the card picture as is. The uniform block must match globecard.vert.
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
vec2 meshSize;
float sphereRadius;
float focalLength;
float lat;
float lon;
};
layout(binding = 1) uniform sampler2D source;
void main()
{
fragColor = texture(source, qt_TexCoord0) * qt_Opacity;
}
+46
View File
@@ -0,0 +1,46 @@
#version 440
// Bends a flat workspace card onto the globe. Each point of the card's grid
// is moved from the card's middle along the sphere, then drawn with the same
// simple perspective as the rest of the globe. The item is centered on the
// middle of the globe.
layout(location = 0) in vec4 qt_Vertex;
layout(location = 1) in vec2 qt_MultiTexCoord0;
layout(location = 0) out vec2 qt_TexCoord0;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
// Size of the card picture, glow margin included.
vec2 meshSize;
float sphereRadius;
float focalLength;
// Where the card's middle sits on the globe, in radians.
float lat;
float lon;
};
out gl_PerVertex {
vec4 gl_Position;
};
void main()
{
qt_TexCoord0 = qt_MultiTexCoord0;
// Distance of this point from the card's middle, in pixels.
vec2 local = qt_Vertex.xy - meshSize * 0.5;
// Walk that far over the sphere. Sideways steps are measured along the
// card's own line of latitude, which gets shorter toward the poles.
float pointLat = lat + local.y / sphereRadius;
float pointLon = lon + local.x / (sphereRadius * max(cos(lat), 0.2));
float c = cos(pointLat);
float depth = sphereRadius * (1.0 - c * cos(pointLon));
float s = focalLength / (focalLength + depth);
vec2 projected = vec2(sphereRadius * c * sin(pointLon), sphereRadius * sin(pointLat)) * s;
gl_Position = qt_Matrix * vec4(projected + meshSize * 0.5, 0.0, 1.0);
}