Search code examples
i3

I3wm config randomly runs (or not) scripts


In my i3 config file I have many scripts that I want to run when i3 starts, including a script to select a wallpaper and another to run polybar. Both of these scripts worked perfectly for more than a year, but suddenly they started behaving strangely: sometimes none of them run, sometimes just one of them run and sometimes only half of the script runs (wtf).

What I mean by only running half of the script is that, for example, polybar might kill all instances of polybar (first line) but not run my bar (second line), or the wal script might change the colors as intended, but not set the wallpaper.

All other scripts in the config run perfectly fine, except for these two. Running them individually in the terminal always works.

This is a part of .config/i3/config:

exec_always --no-startup-id /usr/bin/change-wallpaper
exec_always --no-startup-id $HOME/.config/polybar/launch.sh

This is change-wallpaper (I use pywal):

#!/bin/sh
files=(/home/marlon/Pictures/Wallpapers/*)
wal -i "${files[RANDOM % ${#files[@]}]}"

And this is the script for launching polybar:

#!/usr/bin/env bash
killall -q polybar
polybar bar1 >>/tmp/polybar1.log 2>&1 &

If I remove the change-wallpaper from the config, polybar runs perfectly fine all the time.

I have already tried using the full path, change the order, use only one script that does both of these things, but nothing worked so far.


Solution

  • If, as you say, only half the script runs. Most likely, the parts that apparently don't run, they do actually run, but fail for some reason and you don't see the effect those commands normally have.

    Programs generally write some kind of error messages in these cases. So this is mostly a debugging issue. For polybar, you already redirect the output to a logfile at /tmp/polybar1.log. This file will most likely contain information about why the bar couldn't start.

    I suggest you do the same for your pywal script to see why it fails to set the wallpaper.