Claude pog?
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(dir:*)",
|
||||||
|
"Bash(cat:*)",
|
||||||
|
"Bash(git ls-tree:*)",
|
||||||
|
"Bash(cd:*)"
|
||||||
|
],
|
||||||
|
"deny": [],
|
||||||
|
"ask": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.claude/
|
||||||
@@ -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
@@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
find "$HOME/.config/quickshell/QtDesktopPet/Gifs/" -type f
|
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user