feat: output selected path to stdout

This commit is contained in:
2026-01-15 01:54:38 +01:00
parent b3d2bec75a
commit bd611d7082
3 changed files with 29 additions and 13 deletions
+18 -3
View File
@@ -17,11 +17,11 @@ It might not be that worthy to write a QtWidget application for such a small fea
2. Clone the repository:
```bash
git clone https://github.com/Uyanide/Wallpaper_Carousel.git --depth 1
git clone https://github.com/Uyanide/Wallpaper_Carousel.git --depth 1 && \
cd Wallpaper_Carousel
```
3. Run build script:
3. Run [build script](app/install.sh):
```bash
app/install.sh
@@ -33,7 +33,7 @@ It might not be that worthy to write a QtWidget application for such a small fea
PREFIX=$HOME/.local ./app/install.sh
```
> [!NOTE]
> [Warning]
>
> This script will ask for `sudo` permission if the prefix is set to a system directory like `/usr/local`. Please make sure you have read and trust the script before proceeding.
@@ -50,3 +50,18 @@ A minimum config should at least contain the path(s) to wallpapers, e.g.
}
}
```
By default, the path of the selected wallpaper will be output to stdout. If you want to apply the selected wallpaper automatically after selection, the `action.confirm` entry should be set, e.g.
```json
{
"wallpaper": {
"dirs": ["/path/to/your/wallpapers"]
},
"action": {
"confirm": "awww img \"%1\""
}
}
```
`action.confirm` should be a executable followed by a couple of arguments, where `%1` will be replaced by the path of the selected wallpaper.
+9 -10
View File
@@ -1,7 +1,7 @@
/*
* @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-05 00:37:58
* @LastEditTime: 2026-01-15 01:00:12
* @LastEditTime: 2026-01-15 01:43:14
* @Description: Entry point.
*/
#include <qapplication.h>
@@ -30,27 +30,26 @@ static void setLogLevel(int argc, char* argv[]) {
QString arg(argv[i]);
if (arg == "--debug" || arg == "-vvv" || arg == "--verbose") {
Logger::setLogLevel(QtDebugMsg);
break;
return;
} else if (arg == "--info" || arg == "-vv") {
Logger::setLogLevel(QtInfoMsg);
break;
return;
} else if (arg == "--warn" || arg == "-v") {
Logger::setLogLevel(QtWarningMsg);
break;
return;
} else if (arg == "--critical") {
Logger::setLogLevel(QtCriticalMsg);
break;
return;
} else if (arg == "--fatal") {
Logger::setLogLevel(QtFatalMsg);
break;
return;
} else if (arg == "--quiet") {
Logger::quiet();
break;
} else {
return;
}
}
Logger::setLogLevel(QtInfoMsg);
}
}
}
int main(int argc, char* argv[]) {
QApplication a(argc, argv);
+3 -1
View File
@@ -1,7 +1,7 @@
/*
* @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-05 00:37:58
* @LastEditTime: 2026-01-15 00:47:54
* @LastEditTime: 2026-01-15 01:40:30
* @Description: MainWindow implementation.
*/
#include "main_window.h"
@@ -10,6 +10,7 @@
#include <QKeyEvent>
#include <QProcess>
#include <QPushButton>
#include <cstdio>
#include <functional>
#include "./ui_main_window.h"
@@ -241,6 +242,7 @@ void MainWindow::onConfirm() {
return;
}
info(QString("Selected image: %1").arg(path));
puts(path.toStdString().c_str());
const auto cmdOrig = m_config.getActionConfig().confirm;
if (cmdOrig.isEmpty()) {
warn("No action defined for confirmation");