From 07c873563a68c4a9fa6ed3f004cbde9829a1be8b Mon Sep 17 00:00:00 2001 From: Daniil Tsivinsky Date: Thu, 14 Oct 2021 10:49:19 +0300 Subject: [PATCH] Add script to get random wallpaper on sway startup --- bin/get-random-wallpaper.py | 20 ++++++++++++++++++++ sway/config | 11 ++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) create mode 100755 bin/get-random-wallpaper.py diff --git a/bin/get-random-wallpaper.py b/bin/get-random-wallpaper.py new file mode 100755 index 0000000..899c575 --- /dev/null +++ b/bin/get-random-wallpaper.py @@ -0,0 +1,20 @@ +#! /usr/bin/env python3 + +import os +import glob +import random + +homedir = os.environ['HOME'] + +wallpapers = glob.glob(f"{homedir}/Pictures/Wallpapers/*") + +while True: + wallpaper = random.choice(wallpapers) + + if wallpaper.__contains__("README.md"): + continue + else: + break + +print(wallpaper) + diff --git a/sway/config b/sway/config index 47dea64..dc784e9 100644 --- a/sway/config +++ b/sway/config @@ -39,13 +39,11 @@ set $ws10 "10" default_border none smart_borders on focus_follows_mouse no - -gaps inner 8 - +gaps inner 10 floating_modifier $mod normal # Draw wallpaper -output * bg ~/Pictures/Wallpapers/2b.jpeg fill +output * bg `$HOME/dotfiles/bin/get-random-wallpaper.py` fill # Keyboard layout input * { @@ -86,7 +84,7 @@ for_window [class="MuPDF"] floating enable # /_/ \_\___/ |_| \___/|____/ |_/_/ \_\_| \_\|_| # exec_always --no-startup-id $HOME/.config/waybar/launch.sh -exec_always --no-startup-id mako +exec_always --no-startup-id dunst exec_always --no-startup-id inactive-windows-transparency.py @@ -111,6 +109,9 @@ bindsym XF86AudioPrev exec playerctl previous bindsym $mod+Home exec wlshot copy bindsym $mod+Shift+Home exec wlshot save +# Lock screen +bindsym $mod+Shift+s exec --no-startup-id swaylock -i `$HOME/dotfiles/bin/get-random-wallpaper.py` --font FiraCode + # Start a terminal bindsym $mod+Return exec $term