0

I'm running wallch to automatically cycle thru my wallpapers. I have hundreds of them. I created a little application that displays the title of a wallpaper:

export DISPLAY=:0 && /usr/bin/zenity --info --text="$(gsettings get org.gnome.desktop.background picture-uri | cut -c 41-)"

Without the cut, the output is:

'file:///home/frank/Pictures/Wallpapers/Sitka_Harbor.jpg'

with the cut, I get the file name:

Sitka_Harbor.jpg'

I want to get rid of the trailing apostrophe. I've tried various combinations of the cut --output-delimiter, but can't seem to get it to work.

I would be grateful if someone could point me to some code that would return just the file name.

Thanking all,

sadhu

fossfreedom
  • 171,546
  • 47
  • 376
  • 404
Bhante-S
  • 66
  • 1
  • 2

2 Answers2

1

You could try

basename `gsettings get org.gnome.desktop.background picture-uri` \'

assuming you are using BASH.

basename will extract the last name in the path, which is generated using your command to gsettings, put in backticks so it is seen as a command and not a string. The second argument to basename is the terminating characters you want to omit, in this case the apostrophe, which must be escaped using a backslash so it doesn't start a quote on the shell.

Travis G.
  • 1,837
  • 1
  • 13
  • 15
0

If you just want the file name, add:

| sed 's/\'//'
John Oliver
  • 151
  • 6
  • Couldn't figure out how to escape the apostrophes; they are interpreted by the shell. In any case, the solution from @Travis G. works without pipes. Here's the command line: `/usr/bin/zenity --info --text="$(basename `gsettings get org.gnome.desktop.background picture-uri` \')"` – Bhante-S Feb 12 '14 at 05:22