mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-14 06:48:31 +02:00
wallpaper: use argparse
This commit is contained in:
parent
0e1366a77a
commit
1c9a2b1272
1 changed files with 7 additions and 14 deletions
|
@ -5,11 +5,9 @@
|
||||||
# First argument is the directory where the wallpapers can be
|
# First argument is the directory where the wallpapers can be
|
||||||
# found. We use xinerama to know the dimension of each screen.
|
# found. We use xinerama to know the dimension of each screen.
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals, division
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import optparse
|
import argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from Xlib import display
|
from Xlib import display
|
||||||
|
@ -17,37 +15,32 @@ from Xlib.ext import randr
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
parser = optparse.OptionParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_option(
|
parser.add_argument(
|
||||||
"-d",
|
"-d",
|
||||||
"--directory",
|
"--directory",
|
||||||
dest="directory",
|
|
||||||
default=".",
|
default=".",
|
||||||
help="search for images in DIRECTORY",
|
help="search for images in DIRECTORY",
|
||||||
metavar="DIRECTORY",
|
metavar="DIRECTORY",
|
||||||
)
|
)
|
||||||
parser.add_option(
|
parser.add_argument(
|
||||||
"-t",
|
"-t",
|
||||||
"--target",
|
"--target",
|
||||||
dest="target",
|
|
||||||
default="background.png",
|
default="background.png",
|
||||||
help="write background to FILE",
|
help="write background to FILE",
|
||||||
metavar="FILE",
|
metavar="FILE",
|
||||||
)
|
)
|
||||||
parser.add_option(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
"--crop",
|
"--crop",
|
||||||
dest="crop",
|
dest="crop",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="crop image instead of centering them",
|
help="crop image instead of centering them",
|
||||||
)
|
)
|
||||||
parser.add_option(
|
parser.add_argument(
|
||||||
"--compression", default=0, type=int, help="compression level when saving"
|
"--compression", default=0, type=int, help="compression level when saving"
|
||||||
)
|
)
|
||||||
options, args = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
assert not args, "No additional arguments are accepted"
|
|
||||||
|
|
||||||
background = None
|
background = None
|
||||||
|
|
||||||
# Get display size
|
# Get display size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue