Skip to content

Commit 99c608e

Browse files
committed
Add --meta option
Co-Authored-By: François Dinel <fdinel@gmail.com> Closes varietywalls#794.
1 parent 18b5a10 commit 99c608e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

variety/VarietyOptionParser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ def parse_options(arguments, report_errors=True):
107107
),
108108
)
109109

110+
parser.add_option(
111+
"--meta",
112+
action="store_true",
113+
dest="show_meta",
114+
help=_(
115+
"Print the current wallpaper metadata. Used only when the application is already running."
116+
),
117+
)
118+
110119
parser.add_option(
111120
"--set",
112121
"--set-wallpaper",

variety/VarietyWindow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# You should have received a copy of the GNU General Public License along
1515
# with this program. If not, see <http://www.gnu.org/licenses/>.
1616
### END LICENSE
17+
import json
1718
import logging
1819
import os
1920
import random
@@ -2531,6 +2532,13 @@ def _process_command():
25312532

25322533
GObject.timeout_add(3000 if initial_run else 1, _process_command)
25332534

2535+
if options.show_meta:
2536+
try:
2537+
return json.dumps(Util.read_metadata(self.current))
2538+
except Exception:
2539+
logger.exception(lambda: "Could not retrieve metadata for current wallpaper")
2540+
return ""
2541+
25342542
return self.current if options.show_current else ""
25352543
except Exception:
25362544
logger.exception(lambda: "Could not process passed command")

0 commit comments

Comments
 (0)