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: 2. Clone the repository:
```bash ```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 cd Wallpaper_Carousel
``` ```
3. Run build script: 3. Run [build script](app/install.sh):
```bash ```bash
app/install.sh 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 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. > 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 * @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-05 00:37:58 * @Date: 2025-08-05 00:37:58
* @LastEditTime: 2026-01-15 01:00:12 * @LastEditTime: 2026-01-15 01:43:14
* @Description: Entry point. * @Description: Entry point.
*/ */
#include <qapplication.h> #include <qapplication.h>
@@ -30,26 +30,25 @@ static void setLogLevel(int argc, char* argv[]) {
QString arg(argv[i]); QString arg(argv[i]);
if (arg == "--debug" || arg == "-vvv" || arg == "--verbose") { if (arg == "--debug" || arg == "-vvv" || arg == "--verbose") {
Logger::setLogLevel(QtDebugMsg); Logger::setLogLevel(QtDebugMsg);
break; return;
} else if (arg == "--info" || arg == "-vv") { } else if (arg == "--info" || arg == "-vv") {
Logger::setLogLevel(QtInfoMsg); Logger::setLogLevel(QtInfoMsg);
break; return;
} else if (arg == "--warn" || arg == "-v") { } else if (arg == "--warn" || arg == "-v") {
Logger::setLogLevel(QtWarningMsg); Logger::setLogLevel(QtWarningMsg);
break; return;
} else if (arg == "--critical") { } else if (arg == "--critical") {
Logger::setLogLevel(QtCriticalMsg); Logger::setLogLevel(QtCriticalMsg);
break; return;
} else if (arg == "--fatal") { } else if (arg == "--fatal") {
Logger::setLogLevel(QtFatalMsg); Logger::setLogLevel(QtFatalMsg);
break; return;
} else if (arg == "--quiet") { } else if (arg == "--quiet") {
Logger::quiet(); Logger::quiet();
break; return;
} else { }
}
Logger::setLogLevel(QtInfoMsg); Logger::setLogLevel(QtInfoMsg);
}
}
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
+3 -1
View File
@@ -1,7 +1,7 @@
/* /*
* @Author: Uyanide pywang0608@foxmail.com * @Author: Uyanide pywang0608@foxmail.com
* @Date: 2025-08-05 00:37:58 * @Date: 2025-08-05 00:37:58
* @LastEditTime: 2026-01-15 00:47:54 * @LastEditTime: 2026-01-15 01:40:30
* @Description: MainWindow implementation. * @Description: MainWindow implementation.
*/ */
#include "main_window.h" #include "main_window.h"
@@ -10,6 +10,7 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QProcess> #include <QProcess>
#include <QPushButton> #include <QPushButton>
#include <cstdio>
#include <functional> #include <functional>
#include "./ui_main_window.h" #include "./ui_main_window.h"
@@ -241,6 +242,7 @@ void MainWindow::onConfirm() {
return; return;
} }
info(QString("Selected image: %1").arg(path)); info(QString("Selected image: %1").arg(path));
puts(path.toStdString().c_str());
const auto cmdOrig = m_config.getActionConfig().confirm; const auto cmdOrig = m_config.getActionConfig().confirm;
if (cmdOrig.isEmpty()) { if (cmdOrig.isEmpty()) {
warn("No action defined for confirmation"); warn("No action defined for confirmation");