Sample Header Ad - 728x90

How can I get feh to set wallpaper to each monitor according to its size?

3 votes
2 answers
11833 views
I have a directory filled with png files $ tree ~/wallpaper/ ~/wallpaper/ ├── foo--1366x768.png ├── foo--1920x1080.png ├── foo--2048x1080.png ├── foo--3440x1440.png └── foo--3840x2160.png 0 directories, 5 files I'm often changing monitors, sometimes with multiple attached. I want a script that detects the sizes of the monitors attached to my computer and sets the wallpaper from ~/wallpaper according to the monitor's size. So, if monitors with resolutions 1366x768 and 3440x1440 are connected, I want the script to set the wallpapers to ~/wallpaper/foo--1366x768.png and ~/wallpaper/foo--3440x1440.png respectively. In this particular example, I know that issuing the command feh --bg-fill ~/wallpaper/foo--1366x768.png ~/wallpaper/foo--3440x1440.png will set the wallpapers correctly. To solve the general problem, I know I can issue xrandr | grep ' connected' | awk '{print $3}' | cut -f1 -d"+" to get the dimensions of the monitors attached. In our running example, the output here is: 1366x768 3440x1440 I want to now somewhow pipe this into a command to set the wallpaper with feh. How can I do this?
Asked by Brian Fitzpatrick (2907 rep)
Sep 4, 2019, 06:30 PM
Last activity: May 28, 2021, 06:01 AM