You are not logged in.
I'm trying to make a right click menu option that opens up the current wallpaper that feh set up using
WPCURRENT="$(shuf -n1 -e ~/Pictures/Wallpapers/*)"
feh --randomize --bg-fill "${WPCURRENT}"
It's located in the ~/.fehbg.sh file:
#!/bin/sh
feh --no-fehbg --bg-fill '/home/username/Pictures/Wallpapers/harbour-3731x2721.jpg'
how do i open it in a image viewer like xviewer?
I'm using obmenu generator btw:
{item => ['command', 'Open wallpaper', 'Open wallpaper']},
Last edited by Aldebaraan (2020-07-19 19:16:53)
Offline
cat the script and pipe the text to eg awk, to extract the image filename
IMG=$(cat yourscript.sh | awk -F "'|/" '{print $9}')
Awk is using either "/" or "'" as the field delimiter. You may have to experiment with the field number, which I have guessed is 9!
Other options are to use sed, or bash parameter expansion, to extract the text. Or write the original image variable to another dotfile, and read that directly.
Put it in a script with the image viewer command, and run the script how you want.
#!/bin/sh
IMG=$(cat yourscript.sh | awk -F "'|/" '{print $9}')
bl-image-viewer "${IMG}" &
exit
Last edited by damo (2020-07-15 19:29:21)
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
I think this would be a better way that will work as long as the command line in ~/.fehbg.sh is correctly escaped, and as long as feh comes first:
WALLPAPER_PATH=$(feh () { printf "%s\n" "${!#}"; exit 0; } && source ~/.fehbg.sh)
Not sourcing the file is more secure and better style though, however, since it is a script, the only way to get the result is to interpet it like a shell. That can be done for example using this Python script:
#!/usr/bin/env python3
import os
import shlex
with open(os.path.expanduser("~/.fehbg.sh"), "r") as FILE:
for line in FILE:
if line.startswith("feh"):
print(shlex.split(line)[-1])
break
raise SystemExit(0)
Offline
Uh i tried that and got a error in xviewer that no image was found.
Feh is adding a space to the end of the filename so maybe that's why:
#!/bin/sh
feh --no-fehbg --bg-fill '/home/username/Pictures/Wallpapers/8d326dfd84adfcec91f7b13e184134e8601 .jpg'
I tried:
#!/bin/sh
IMG=$(cat ~/.fehbg.sh | awk -F "'|/" '{print $9}')
xviewer "${IMG}" &
exit
Maybe extracting the variable and writing to a txt file should work? I don't know how to do that.
This is the script that changes the wallpaper. It is called inside .conkyrc:
#!/bin/bash
WPCURRENT="$(shuf -n1 -e ~/Pictures/Wallpapers/*)"
feh --recursive --randomize --bg-fill "${WPCURRENT}"
color=`convert "${WPCURRENT}" -gravity east -crop 20%x100% -resize 1x1 -negate txt:- | tail -n1 |cut -d' ' -f4`
echo -n '${color '$color'}' > ~/.config/openbox/wallchange/color.txt
echo -n ${WPCURRENT} > ~/.config/openbox/wallchange/currentwallpaper.txt
cat ~/.config/openbox/wallchange/color.txt
trying to write WPCURRENT to currentwallpaper writes only the folder path and not the filename with extension.
Last edited by Aldebaraan (2020-07-15 20:40:08)
Offline
@nobody,
What is that () magic?
Subshell?
feh ()
Last edited by brontosaurusrex (2020-07-16 11:15:39)
Offline
@nobody,
What is that () magic?
Subshell?feh ()
Just a function declaration on 1 line It replaces the feh command in the PATH with the defined function of the same name (or alias) unless feh is then called using "command feh".
Offline
Fancy. And shame on me to not recognize a function...
Last edited by brontosaurusrex (2020-07-16 11:31:56)
Offline
@all: you seem to be ignoring the fact that shuf will return a different image each time the script runs.
@Aldebaraan: use .fehbg - the current bg image name is stored in ~/.fehbg and you can grep it from there thusly:
cut -d\' -f2 ~/.fehbg | tail -1
BTW, why don't you use feh as the image viewer...
Last edited by ohnonot (2020-07-17 08:17:49)
Offline
Managed to make it work:
This picks a random wallpaper, saves the path and filename to currentwallpaper.txt:
#!/bin/bash
WPCURRENT="$(find ~/Pictures/Wallpapers/ -type f |shuf -n1)"
feh --recursive --bg-fill "${WPCURRENT}"
color=`convert "${WPCURRENT}" -gravity east -crop 20%x100% -resize 1X1 -negate txt:- | tail -n1 |cut -d' ' -f4`
echo -n '${color '$color'}' > ~/.config/openbox/wallchange/color.txt
echo -n ${WPCURRENT} > ~/.config/openbox/wallchange/currentwallpaper.txt
cat ~/.config/openbox/wallchange/color.txt
This opens the image:
#!/bin/sh
IMG=$(cat ~/.config/openbox/wallchange/currentwallpaper.txt | awk -F "'|/" '{print $0}')
xviewer "${IMG}" &
exit
Obmenu schema:
{item => ['bash ~/.config/openbox/wallchange/open-wallpaper.sh', 'Open wallpaper', 'xviewer']},
{item => ['bash ~/.config/openbox/wallchange/next-wallpaper.sh', 'Next wallpaper', 'xviewer']},
Next i will try to make a history file for a 'Previous wallpaper' button. Thanks everyone!
Offline
saves the path and filename to currentwallpaper.txt
Why, when this is exactly what ~/.fehbg does!
Also the "--recursive" is nonsensical in your feh command.
What does the convert part do?
BTW, the usage of `backticks` is discouraged, you should use $(command) instead.
Anyhow, glad you solved it.
Please edit your first post and prepend "[SOLVED]" to the title.
Offline
And if you just want to open the image for viewing you can use feh for that as well.
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
What does the convert part do?
It's for conky:
conky.text = [[
${execpi 180 bash ~/.config/openbox/wallchange/wallchange.sh}
${execpi 5 cat ~/.config/openbox/wallchange/color.txt}
It changes the color used depending on the wallpaper.
Anyhow, glad you solved it.
Please edit your first post and prepend "[SOLVED]" to the title.
Done
And if you just want to open the image for viewing you can use feh for that as well.
I don't use feh as image viewer because there's no zoom and neither a open image location button.
Offline
...
damo wrote:And if you just want to open the image for viewing you can use feh for that as well.
I don't use feh as image viewer because there's no zoom and neither a open image location button.
man feh
...
⟨keypad +⟩, ⟨Up⟩ [zoom_in]
Zoom in
⟨keypad -⟩, ⟨Down⟩ [zoom_out]
Zoom out
*, ⟨keypad *⟩ [zoom_default]
Zoom to 100%
/, ⟨keypad /⟩ [zoom_fit]
Zoom to fit the window size
! [zoom_fill]
Zoom to fill the window size like --bg-fill
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
I don't use feh as image viewer because there's no zoom and neither a open image location button.
There is a zoom features on feh,
zoom_in 4
zoom_out 5
Place those to a file called buttons on /home/your-username/.config/feh/buttons
Then use the middle button from your mouse up and down to zoom in / zoom out.
Regarding the 2nd request, i just use File Manager to generate the thumbs then i open with feh. But i know there are a few scripts that help you to achieve the required purpose of browsing the images.
See more here if it helps you.
https://forums.bunsenlabs.org/viewtopic.php?id=704
Tumbleweed (Server) | KDE Plasma (Wayland)
Offline
Aldebaraan wrote:...
damo wrote:And if you just want to open the image for viewing you can use feh for that as well.
I don't use feh as image viewer because there's no zoom and neither a open image location button.
man feh ... ⟨keypad +⟩, ⟨Up⟩ [zoom_in] Zoom in ⟨keypad -⟩, ⟨Down⟩ [zoom_out] Zoom out *, ⟨keypad *⟩ [zoom_default] Zoom to 100% /, ⟨keypad /⟩ [zoom_fit] Zoom to fit the window size ! [zoom_fill] Zoom to fill the window size like --bg-fill
Aldebaraan wrote:I don't use feh as image viewer because there's no zoom and neither a open image location button.
There is a zoom features on feh,
zoom_in 4 zoom_out 5
Place those to a file called buttons on /home/your-username/.config/feh/buttons
Then use the middle button from your mouse up and down to zoom in / zoom out.Regarding the 2nd request, i just use File Manager to generate the thumbs then i open with feh. But i know there are a few scripts that help you to achieve the required purpose of browsing the images.
See more here if it helps you.
https://forums.bunsenlabs.org/viewtopic.php?id=704
Thanks.
Offline