Add terminal spawning quickshell config

This commit is contained in:
outfoxxed 2024-03-20 01:48:56 -07:00
parent 6a824b8a58
commit 8364a3b9b9
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
9 changed files with 308 additions and 72 deletions

View file

@ -4,4 +4,5 @@ import Quickshell
Image {
required property ShellScreen screen;
source: Qt.resolvedUrl(screen.name == "DP-1" ? "5120x1440.png" : "1920x1080.png")
asynchronous: false
}

View file

@ -1,31 +0,0 @@
import Quickshell
import Quickshell.Wayland
import QtQuick
import ".."
ShellRoot {
Variants {
model: Quickshell.screens
PanelWindow {
id: window
property var modelData
screen: modelData
WlrLayershell.layer: WlrLayer.Background
anchors {
top: true
bottom: true
left: true
right: true
}
color: "#111111"
BackgroundImage {
anchors.fill: parent
screen: window.screen
}
}
}
}

View file

@ -2,12 +2,13 @@
inherit (inputs) quickshell;
in {
home.packages = with pkgs; [
qt6.qtimageformats # amog
quickshell.packages.${system}.default
pamtester # lockscreen
];
xdg.configFile."quickshell/manifest.conf".text = lib.generators.toKeyValue {} {
background = impurity.link ./background;
shell = impurity.link ./shell;
lockscreen = impurity.link ./lockscreen;
};
}

View file

@ -0,0 +1,27 @@
import QtQuick
Item {
id: root
required property var screen;
required property var selectionArea;
signal selectionComplete(x: real, y: real, width: real, height: real)
MouseArea {
anchors.fill: parent
onPressed: {
selectionArea.startX = mouseX;
selectionArea.startY = mouseY;
selectionArea.endX = mouseX;
selectionArea.endY = mouseY;
selectionArea.selecting = true;
}
onPositionChanged: {
selectionArea.endX = mouseX;
selectionArea.endY = mouseY;
}
onReleased: selectionArea.endSelection();
}
}

View file

@ -0,0 +1,87 @@
import QtQuick
import Quickshell
import Quickshell.Wayland
WlrLayershell {
signal selectionComplete(x: real, y: real, width: real, height: real)
color: "transparent"
visible: selectionArea.selecting || selectionArea.initializing
layer: WlrLayer.Overlay
namespace: "termspawner"
anchors {
left: true
right: true
top: true
bottom: true
}
property var selectionArea: area
Rectangle {
id: area
property bool selecting: false
property bool initializing: false
property real startX: 0
property real startY: 0
property real endX: 0
property real endY: 0
readonly property bool bigEnough: width > 50 && height > 50
border.color: bigEnough ? "#ee33ccff" : "#aa595959"
border.width: 1
radius: 5
color: "#66001017"
visible: selecting
x: Math.min(startX, endX)
y: Math.min(startY, endY)
width: Math.max(startX, endX) - x
height: Math.max(startY, endY) - y
function startSelection() {
initializing = true
if (selecting) {
area.startX = mouseArea.mouseX;
area.startY = mouseArea.mouseY;
area.endX = mouseArea.mouseX;
area.endY = mouseArea.mouseY;
}
}
function endSelection() {
const wasSelecting = selecting;
selecting = false;
initializing = false;
if (wasSelecting && bigEnough) {
selectionComplete(x, y, width, height);
}
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onPositionChanged: {
if (area.initializing) {
if (!containsMouse) {
area.initializing = false;
return;
}
area.startX = mouseX;
area.startY = mouseY;
area.initializing = false;
area.selecting = true;
}
area.endX = mouseX;
area.endY = mouseY;
}
}
}

View file

@ -0,0 +1,31 @@
pragma Singleton
import Quickshell
import Quickshell.Io
Singleton {
property bool termSelect: false;
SocketServer {
active: true
path: "/run/user/1000/quickshell.sock"
handler: Socket {
parser: SplitParser {
onRead: message => {
console.log(message)
switch (message) {
case "termselect:start":
termSelect = true;
break;
case "termselect:stop":
termSelect = false;
break;
default:
console.log(`socket received unknown message: ${message}`)
}
}
}
}
}
}

View file

@ -0,0 +1,117 @@
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import QtQuick
import QtQuick.Layouts
import ".."
ShellRoot {
Variants {
model: Quickshell.screens
Scope {
property var modelData
PanelWindow {
id: window
screen: modelData
WlrLayershell.layer: WlrLayer.Background
anchors {
top: true
bottom: true
left: true
right: true
}
color: "#111111"
BackgroundImage {
anchors.fill: parent
screen: window.screen
}
SelectionLayer {
id: selectionLayer
onSelectionComplete: (x, y, width, height) => {
console.log(`selection complete: ${x} ${y} ${width} ${height}`)
termSpawner.x = x
termSpawner.y = y
termSpawner.width = width
termSpawner.height = height
termSpawner.running = true
}
Process {
id: termSpawner
property real x;
property real y;
property real width;
property real height;
command: ["hyprctl", "dispatch", "exec", `[float;; noanim; move ${x} ${y}; size ${width} ${height}] alacritty`]
}
Connections {
target: ShellIpc
function onTermSelectChanged() {
if (ShellIpc.termSelect) {
selectionLayer.selectionArea.startSelection();
} else {
selectionLayer.selectionArea.endSelection();
}
}
}
}
SelectionArea {
anchors.fill: parent
screen: window.screen
selectionArea: selectionLayer.selectionArea
}
}
PanelWindow {
screen: modelData
WlrLayershell.layer: WlrLayer.Overlay
anchors {
right: true
bottom: true
}
margins {
right: 50
bottom: 50
}
width: content.width
height: content.height
color: "transparent"
mask: Region {}
ColumnLayout {
id: content
Text {
text: "Activate Linux"
color: "#50ffffff"
font.pointSize: 22
}
Text {
text: "Go to Settings to activate Linux"
color: "#50ffffff"
font.pointSize: 14
}
}
}
}
}
}