Claude pog?

This commit is contained in:
2025-12-03 13:53:58 +01:00
parent 089a5f7a49
commit 8967e3a1f5
7 changed files with 179 additions and 8 deletions
+12
View File
@@ -0,0 +1,12 @@
{
"permissions": {
"allow": [
"Bash(dir:*)",
"Bash(cat:*)",
"Bash(git ls-tree:*)",
"Bash(cd:*)"
],
"deny": [],
"ask": []
}
}
+1
View File
@@ -0,0 +1 @@
.claude/
+131
View File
@@ -0,0 +1,131 @@
import QtCore
import QtQuick
import Quickshell.Io
QtObject {
id: configLoader
property string gifFolder: ""
property bool loaded: false
property string configDir: StandardPaths.homeLocation + "/.config/QTPet"
property string configPath: configDir + "/config.json"
signal folderChanged()
// Process to check/create directory
property var dirCheckProcess: Process {
id: dirCheck
running: false
command: ["test", "-d", configLoader.configDir]
onExited: {
if (exitCode !== 0) {
// Directory doesn't exist, create it
dirCreateProcess.running = true
} else {
// Directory exists, check for config file
fileCheckProcess.running = true
}
}
}
// Process to create directory
property var dirCreateProcess: Process {
id: dirCreate
running: false
command: ["mkdir", "-p", configLoader.configDir]
onExited: {
console.log("Created config directory:", configLoader.configDir)
// After creating directory, create default config
fileCreateProcess.running = true
}
}
// Process to check if config file exists
property var fileCheckProcess: Process {
id: fileCheck
running: false
command: ["test", "-f", configLoader.configPath]
onExited: {
if (exitCode !== 0) {
// File doesn't exist, create default config
fileCreateProcess.running = true
} else {
// File exists, load it
loadConfig()
}
}
}
// Process to create default config file
property var fileCreateProcess: Process {
id: fileCreate
running: false
command: ["sh", "-c", "echo '{\"gifFolder\": \"$HOME/.config/quickshell/QtDesktopPet/Gifs\"}' > " + configLoader.configPath]
onExited: {
console.log("Created default config file:", configLoader.configPath)
loadConfig()
}
}
// Timer to watch for config file changes
property var configWatcher: Timer {
id: watcher
interval: 2000 // Check every 2 seconds
running: configLoader.loaded
repeat: true
property string lastContent: ""
onTriggered: {
try {
let currentContent = Qt.readFile(configLoader.configPath)
if (lastContent !== "" && currentContent !== lastContent) {
console.log("Config file changed, reloading...")
loadConfig()
configLoader.folderChanged()
}
lastContent = currentContent
} catch (e) {
// File might have been deleted, ignore
}
}
}
function loadConfig() {
try {
let configText = Qt.readFile(configPath)
let configData = JSON.parse(configText)
// Replace $HOME with actual home directory
let newFolder = configData.gifFolder.replace("$HOME", StandardPaths.homeLocation)
if (gifFolder !== newFolder && loaded) {
// Folder changed, emit signal
gifFolder = newFolder
folderChanged()
} else {
gifFolder = newFolder
}
loaded = true
// Initialize watcher's lastContent on first load
if (watcher.lastContent === "") {
watcher.lastContent = configText
}
} catch (e) {
console.error("Failed to load config:", e)
// Fallback to default path
gifFolder = StandardPaths.homeLocation + "/.config/quickshell/QtDesktopPet/Gifs"
loaded = true
}
}
Component.onCompleted: {
// Start the check/create chain
dirCheckProcess.running = true
}
}
+22 -2
View File
@@ -2,12 +2,32 @@ import Quickshell.Io
Process { Process {
id: getGifsProcess id: getGifsProcess
required property string gifFolder
property list<string> gifsList: [] property list<string> gifsList: []
command: ["sh", "-c", "$HOME/.config/quickshell/QtDesktopPet/Scripts/files.sh"]
command: ["find", gifFolder, "-type", "f", "-name", "*.gif"]
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
var gifs = this.text.trim().split("\n") var gifs = this.text.trim().split("\n")
getGifsProcess.gifsList = gifs if (gifs.length > 0 && gifs[0] !== "") {
getGifsProcess.gifsList = gifs
} else {
getGifsProcess.gifsList = []
}
}
}
function reload() {
// Clear current list and restart the process
gifsList = []
running = false
running = true
}
onGifFolderChanged: {
if (running) {
reload()
} }
} }
} }
+2 -1
View File
@@ -8,10 +8,11 @@ Repeater {
property int lastWidth property int lastWidth
model: gifsList model: gifsList
Item { Item {
x: gifRepeater.itemAt(index - 1).x + gifRepeater.itemAt(index - 1).width x: index === 0 ? 0 : gifRepeater.itemAt(index - 1).x + gifRepeater.itemAt(index - 1).width
y: Screen.height - height y: Screen.height - height
width: gif.width width: gif.width
height: gif.height height: gif.height
AnimatedImage { AnimatedImage {
id: gif id: gif
source: modelData source: modelData
-3
View File
@@ -1,3 +0,0 @@
#!/bin/zsh
find "$HOME/.config/quickshell/QtDesktopPet/Gifs/" -type f
+11 -2
View File
@@ -27,11 +27,20 @@ PanelWindow {
bottom: 9 bottom: 9
} }
ConfigLoader {
id: configLoader
onFolderChanged: {
console.log("Folder changed to:", gifFolder)
getGifs.reload()
}
}
GetGifs { GetGifs {
id: getGifs id: getGifs
running: true gifFolder: configLoader.gifFolder
running: configLoader.loaded
} }
GifsLoader { GifsLoader {
id: gifloader id: gifloader
gifsList: getGifs.gifsList gifsList: getGifs.gifsList