diff --git a/shell/bar/Bar.qml b/shell/bar/Bar.qml index 746134d..966b507 100644 --- a/shell/bar/Bar.qml +++ b/shell/bar/Bar.qml @@ -40,7 +40,6 @@ Variants { // Left side of bar RowLayout { spacing: 15 - Layout.fillWidth: true Layout.fillHeight: true Layout.alignment: Qt.AlignLeft @@ -94,6 +93,7 @@ Variants { Clock { id: clock color: ShellSettings.colors.active + Layout.leftMargin: 5 } } } diff --git a/shell/screencapture/Controller.qml b/shell/screencapture/Controller.qml index 7827b0f..a6fcaa4 100644 --- a/shell/screencapture/Controller.qml +++ b/shell/screencapture/Controller.qml @@ -5,6 +5,7 @@ import Quickshell import Quickshell.Io import Quickshell.Wayland import QtQuick +import qs Singleton { id: root @@ -53,10 +54,30 @@ Singleton { const height = Math.floor(selection.height); let position = `${x},${y} ${width}x${height}`; - let path = "/home/koss/Pictures/screenshot.png"; + + // i hate javascript + let date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth(); + let day = date.getDay(); + let dateString = `${year}-${month}-${day}`; + + let hour = date.getHours(); + let minutes = date.getMinutes(); + let seconds = date.getSeconds(); + let timeString = `${hour}:${minutes}:${seconds}`; + + let fileName = `screenshot-${dateString}-${timeString}.png` + const path = `${ShellSettings.settings.screenshotPath}/${fileName}`; + + console.log(`Screenshot saved to ${path}`); + + // take a screenshot with grim, probably a better way to get this path... + let scriptUrl = Qt.resolvedUrl("root:scripts/screenshot.sh").toLocaleString(); + let scriptPath = scriptUrl.replace(/^(file:\/{2})/, ""); Quickshell.execDetached({ - command: ["grim", "-g", position, path] + command: ["sh", scriptPath, position, path] }); root.windowOpen = false; diff --git a/shell/screencapture/SelectionRectangle.qml b/shell/screencapture/SelectionRectangle.qml index ec205e5..71df1cf 100644 --- a/shell/screencapture/SelectionRectangle.qml +++ b/shell/screencapture/SelectionRectangle.qml @@ -9,10 +9,17 @@ Item { property color overlayColor: "#80000000" property rect selectionRect: Qt.rect(0, 0, 0, 0) property point startPosition: Qt.point(0, 0) + property real borderSize: 2 + signal areaSelected(rect selection) - - // only send signal when selection rectangle has finished - onVisibleChanged: areaSelected(selectionRect) + + // only send signal when selection rectangle has finished + onVisibleChanged: { + if (!visible) + selectionRect.width -= borderSize; + selectionRect.height -= borderSize; + areaSelected(selectionRect); + } MouseArea { id: selectionArea @@ -94,7 +101,7 @@ Item { id: rectangle color: "transparent" border.color: ShellSettings.colors.active_translucent - border.width: 2 + border.width: root.borderSize x: 0 y: 0 width: 0 diff --git a/shell/scripts/screenshot.sh b/shell/scripts/screenshot.sh new file mode 100644 index 0000000..04f81ae --- /dev/null +++ b/shell/scripts/screenshot.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +# Very basic script for taking a screenshot and then +# copying it the clipboard + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +# create directory if doesn't already exist +mkdir -p ~/Pictures + +# 1 - Geometry +# 2 - Path +grim -g "$1" $2 +wl-copy <$2