I would like to type the following command in a css file.
background: #2c001e url(file:///home/user/.local/share/backgrounds/mypic.jpg)
However, I don't want to explicitly declare the user path /home/user/
but instead use ~
and $HOME
in its place. I discovered they did not work, i.e.
background: #2c001e url(file://~/.local/share/backgrounds/mypic.jpg)
background: #2c001e url(file://$HOME.local/share/backgrounds/mypic.jpg)
What is the correct syntax that I should use?
The context for using the above command is described here.
$HOME
should work fine. You just forgot a/
after$HOME
. – BeastOfCaerbannog Oct 01 '19 at 15:45background: #2c001e url(file://$HOME/.local/share/backgrounds/mypic.jpg)
but it still did not work...puzzled? I ran Alt+F2+r+return to refresh the GDM but they still did not work. – Sun Bear Oct 01 '19 at 15:58background: #2c001e url(file:///home/user/.local/share/backgrounds/mypic.jpg)
, works? – BeastOfCaerbannog Oct 01 '19 at 16:06~
and$HOME
are system variables. The browser does not know about them. So in this case you should always use the full path. Maybe I'm wrong? – schrodingerscatcuriosity Oct 01 '19 at 16:06google-chrome file://$HOME/path/to/file
in the terminal and it worked fine. But it worked fine exactly because I ran it in the terminal, which can "convert" the$HOME
system variable to my actual home path. When the css file is read, it's the browser that does the reading, which, as guillermo said, does not know about system variables. – BeastOfCaerbannog Oct 01 '19 at 16:31resource
command (leveraging on GNOME). – Sun Bear Oct 01 '19 at 18:05