Commit 79bb160d authored by Benedikt Vollmerhaus's avatar Benedikt Vollmerhaus

Add ranger config and custom wal command

parent e7450303
"""
Custom commands for the ranger file manager.
Author: Benedikt Vollmerhaus
License: MIT
"""
from typing import Tuple
from ranger.api.commands import Command
from ranger.ext.get_executables import get_executables
class wal(Command):
"""
:wal [filename] [alpha [background]]
Generate a color scheme using Pywal with the selected or a given image.
"""
DEFAULT_ALPHA = 95
DEFAULT_BACKGROUND = '#0a0a0a'
def execute(self) -> None:
"""
Check whether Pywal is installed and run it with the given arguments.
:return: None
"""
if 'wal' not in get_executables():
self.fm.notify('Could not find Pywal in PATH.', bad=True)
return
(image_filename, alpha, background) = self.get_arguments()
self.fm.notify(f"Running pywal using {image_filename}.")
self.fm.execute_command(f'wal -i "{image_filename}" '
f'-a {alpha} -b "{background}"')
def get_arguments(self) -> Tuple[str, int, str]:
"""
Parse and return a tuple with the arguments passed to the command.
:return: A tuple with the chosen image, alpha and background color
"""
image_filename = self.fm.thisfile.path
alpha = self.DEFAULT_ALPHA
background = self.DEFAULT_BACKGROUND
if self.arg(1) and not self.arg(1).isdigit():
image_filename = self.arg(1)
self.shift()
if self.arg(1).isdigit():
alpha = self.arg(1)
if self.arg(2):
background = self.arg(2)
return image_filename, alpha, background
def tab(self, _tabnum) -> str:
"""
Tab-complete files in the current directory.
:return: The tab completion result
"""
return self._tab_directory_content()
# ___
# | _ \__ _ _ _ __ _ ___ _ _
# | / _` | ' \/ _` / -_) '_|
# |_|_\__,_|_||_\__, \___|_|
# |___/
#
# Author: Benedikt Vollmerhaus
# License: MIT
set preview_images true
set draw_borders true
set vcs_aware true
......@@ -11,6 +11,9 @@
~/.config/i3/auto_remove_urgency.py: scripts/scripts/auto_remove_urgency.py
~/.config/i3/brightness_notifier.py: scripts/scripts/brightness_notifier.py
~/.config/ranger/commands.py: config/ranger/commands.py
~/.config/ranger/rc.conf: config/ranger/rc.conf
~/.config/polybar: config/polybar
~/.vimrc: vimrc
~/.Xresources: Xresources
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment