示例#1
0
 def get_info(cls):
     return {
         "name":
         "Local text files",
         "description":
         _("Displays quotes, defined in local text files.\n"
           "Put your own txt files in: {}pluginconfig/quotes/.\n"
           "The file format is:\n\nquote -- author\n.\nsecond quote -- another author\n.\netc...\n\n"
           "Example: http://rvelthuis.de/zips/quotes.txt").format(
               get_profile_path(expanded=False)),
         "author":
         "Peter Levi",
         "version":
         "0.1",
     }
示例#2
0
def _set_up_logging(verbose):
    # add a handler to prevent basicConfig
    root = logging.getLogger()
    null_handler = logging.NullHandler()
    root.addHandler(null_handler)

    formatter = logging.Formatter(
        "%(levelname)s: %(asctime)s: %(funcName)s() '%(message)s'")

    logger = logging.getLogger("variety")
    logger_sh = logging.StreamHandler()
    logger_sh.setFormatter(formatter)
    logger.addHandler(logger_sh)

    try:
        logger_file = logging.FileHandler(
            os.path.join(get_profile_path(), "variety.log"), "w")
        logger_file.setFormatter(formatter)
        logger.addHandler(logger_file)
    except Exception:
        logger.exception("Could not create file logger")

    lib_logger = logging.getLogger("variety_lib")
    lib_logger_sh = logging.StreamHandler()
    lib_logger_sh.setFormatter(formatter)
    lib_logger.addHandler(lib_logger_sh)

    logger.setLevel(logging.INFO)
    # Set the logging level to show debug messages.
    if verbose >= 2:
        logger.setLevel(logging.DEBUG)
    elif not verbose:
        # If we're not in verbose mode, only log these messages to file. This prevents
        # flooding syslog and/or ~/.xsession-errors depending on how variety was started:
        # (https://bugs.launchpad.net/variety/+bug/1685003)
        # XXX: We should /really/ make the internal debug logging use logging.debug,
        # this is really just a bandaid patch.
        logger_sh.setLevel(logging.WARNING)

    if verbose >= 3:
        lib_logger.setLevel(logging.DEBUG)
示例#3
0
 def __init__(self):
     self.configfile = os.path.join(get_profile_path(), "variety.conf")
示例#4
0
    def set_defaults(self):
        self.change_enabled = True
        self.change_on_start = False
        self.change_interval = 300
        self.safe_mode = False

        self.download_folder = os.path.join(get_profile_path(), "Downloaded")
        self.download_preference_ratio = 0.9
        self.quota_enabled = True
        self.quota_size = 1000

        self.favorites_folder = os.path.join(get_profile_path(), "Favorites")
        self.favorites_operations = [
            ["Downloaded", "Copy"],
            ["Fetched", "Move"],
            ["Others", "Copy"],
        ]

        self.fetched_folder = os.path.join(get_profile_path(), "Fetched")
        self.clipboard_enabled = False
        self.clipboard_use_whitelist = True
        self.clipboard_hosts = "wallhaven.cc,ns223506.ovh.net,wallpapers.net,flickr.com,imgur.com,deviantart.com,interfacelift.com,vladstudio.com".split(
            ",")

        self.icon = "Light"

        self.desired_color_enabled = False
        self.desired_color = None
        self.min_size_enabled = False
        self.min_size = 80
        self.use_landscape_enabled = True
        self.lightness_enabled = False
        self.lightness_mode = Options.LightnessMode.DARK
        self.min_rating_enabled = False
        self.min_rating = 4

        self.smart_notice_shown = False
        self.smart_register_shown = False
        self.stats_notice_shown = False

        self.smart_enabled = False
        self.sync_enabled = False
        self.stats_enabled = False

        self.copyto_enabled = False
        self.copyto_folder = "Default"

        self.clock_enabled = False
        self.clock_font = "Ubuntu Condensed, 70"
        self.clock_date_font = "Ubuntu Condensed, 30"
        self.clock_filter = "-density 100 -font `fc-match -f '%{file[0]}' '%CLOCK_FONT_NAME'` -pointsize %CLOCK_FONT_SIZE -gravity SouthEast -fill '#00000044' -annotate 0x0+[%HOFFSET+58]+[%VOFFSET+108] '%H:%M' -fill white -annotate 0x0+[%HOFFSET+60]+[%VOFFSET+110] '%H:%M' -font `fc-match -f '%{file[0]}' '%DATE_FONT_NAME'` -pointsize %DATE_FONT_SIZE -fill '#00000044' -annotate 0x0+[%HOFFSET+58]+[%VOFFSET+58] '%A, %B %d' -fill white -annotate 0x0+[%HOFFSET+60]+[%VOFFSET+60] '%A, %B %d'"

        self.quotes_enabled = False
        self.quotes_font = "Bitstream Charter 30"
        self.quotes_text_color = (255, 255, 255)
        self.quotes_bg_color = (80, 80, 80)
        self.quotes_bg_opacity = 55
        self.quotes_text_shadow = False
        self.quotes_disabled_sources = []
        self.quotes_tags = ""
        self.quotes_authors = ""
        self.quotes_change_enabled = False
        self.quotes_change_interval = 300
        self.quotes_width = 70
        self.quotes_hpos = 100
        self.quotes_vpos = 40
        self.quotes_max_length = 250
        self.quotes_favorites_file = os.path.join(get_profile_path(),
                                                  "favorite_quotes.txt")

        self.slideshow_sources_enabled = True
        self.slideshow_favorites_enabled = True
        self.slideshow_downloads_enabled = False
        self.slideshow_custom_enabled = False
        self.slideshow_custom_folder = Util.get_xdg_pictures_folder()
        self.slideshow_sort_order = "Random"
        self.slideshow_monitor = "All"
        self.slideshow_mode = "Fullscreen"
        self.slideshow_seconds = 6
        self.slideshow_fade = 0.4
        self.slideshow_zoom = 0.2
        self.slideshow_pan = 0.05

        self.sources = [
            [True, Options.SourceType.FAVORITES, "The Favorites folder"],
            [True, Options.SourceType.FETCHED, "The Fetched folder"],
            [True, Options.SourceType.FOLDER, "/usr/share/backgrounds/"],
            [
                True,
                Options.SourceType.FLICKR,
                "user:www.flickr.com/photos/peter-levi/;user_id:93647178@N00;",
            ],
        ]

        self.filters = [
            [False, "Keep original", ""],
            [False, "Grayscale", "-type Grayscale"],
            [False, "Heavy blur", "-blur 120x40"],
            [False, "Oil painting", "-paint 6"],
            [False, "Charcoal painting", "-charcoal 3"],
            [False, "Pointilism", "-spread 10 -noise 3"],
            [False, "Pixellate", "-scale 3% -scale 3333%"],
        ]
示例#5
0
def main():
    # Ctrl-C
    signal.signal(signal.SIGINT, _sigint_handler)
    signal.signal(signal.SIGTERM, _sigint_handler)
    #signal.signal(signal.SIGQUIT, _sigint_handler)

    arguments = sys.argv[1:]

    # validate arguments
    from variety import VarietyOptionParser

    options, args = VarietyOptionParser.parse_options(arguments)
    set_profile_path(options.profile)
    Util.makedirs(get_profile_path())

    # ensure singleton per profile
    bus = dbus.SessionBus()
    dbus_key = _get_dbus_key()
    if bus.request_name(dbus_key) != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        if not arguments or (options.profile and len(arguments) <= 2):
            arguments = ["--preferences"]
        safe_print(
            _("Variety is already running. Sending the command to the running instance."),
            "Variety is already running. Sending the command to the running instance.",
            file=sys.stderr,
        )
        method = bus.get_object(dbus_key, DBUS_PATH).get_dbus_method("process_command")
        result = method(arguments)
        if result:
            safe_print(result)
        return

    # set up logging
    # set_up_logging must be called after the DBus checks, only by one running instance,
    # or the log file can be corrupted
    _set_up_logging(options.verbose)
    logging.getLogger("variety").info(lambda: "Using profile folder {}".format(get_profile_path()))

    if options.verbose >= 3:
        profiler = ModuleProfiler()
        if options.verbose >= 5:
            # The main variety package
            pkgname = os.path.dirname(__file__)
            profiler.log_path(pkgname)

            if options.verbose >= 6:
                # Track variety_lib
                profiler.log_path(pkgname + "_lib")
        else:
            # Cherry-picked log items carried over from variety 0.6.x
            profiler.log_class(VarietyWindow.VarietyWindow)

            if options.verbose >= 4:
                profiler.log_class(ThumbsManager.ThumbsManager)
                profiler.log_class(ThumbsWindow.ThumbsWindow)

        profiler.start()

    # Run the application.
    window = VarietyWindow.VarietyWindow()
    global VARIETY_WINDOW
    VARIETY_WINDOW = window
    service = VarietyService(window)

    bus.call_on_disconnection(window.on_quit)

    window.start(arguments)
    GObject.timeout_add(2000, _check_quit)
    Gtk.main()
示例#6
0
        "Latest favorites by the other users of Variety. [May contain NSFW images]",
        _("Latest favorites by the other users of Variety. [May contain NSFW images]"
          ),
    ),
    "desktoppr": ("Random wallpapers from Desktoppr.co",
                  _("Random wallpapers from Desktoppr.co")),
    "apod": ("NASA's Astronomy Picture of the Day",
             _("NASA's Astronomy Picture of the Day")),
    "bing": ("Bing Photo of the Day", _("Bing Photo of the Day")),
    "unsplash": (
        "High-resolution photos from Unsplash.com",
        _("High-resolution photos from Unsplash.com"),
    ),
}

profile_path = get_profile_path(expanded=False)

TIPS = [
    _("You can change the wallpaper back and forth by scrolling the mouse wheel on top of the indicator icon."
      ),
    _("If you want to run custom commands every time the wallpaper changes or if you use an alternative desktop environment, please edit the scripts in {PROFILE_PATH}scripts. There are examples there for various desktop environments."
      ),
    _('Variety can be controlled from the command line and you can use this to define keyboard shortcuts for the operations you use most often. Run "variety --help" to see all available commands.'
      ),
    _('You can drop image links or files on the launcher icon to download them and use them as wallpapers. For quicker downloading from a specific site, you can also use clipboard monitoring (see "Manual downloading" tab).'
      ),
    _("Applying a heavy blurring filter is a great way to get abstract-looking and unobtrusive, yet colorful wallpapers, similar in spirit to the default one in Ubuntu."
      ),
    _("Adding your own custom filters is quite easy: open {PROFILE_PATH}variety.conf in an editor and use the existing filters as an example. Every filter is just a line of options to be passed to ImageMagick's convert command."
      ),
    _('When you select an image source, its images are displayed in a window at the bottom of the screen. Click an image there to set is as wallpaper. Right-click to close the window, to modify its appearance or to perform file operations. You can select multiple image sources to create a "merged" thumbnail view of all of them. Please mind that thumbnail view is limited to several hundred randomly selected images.'