specialFolderPaths("documents") returns empty string on linux LXLE

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

slowmaker
Posts: 13
Joined: Fri Feb 08, 2019 1:53 pm

specialFolderPaths("documents") returns empty string on linux LXLE

Post by slowmaker » Fri Feb 08, 2019 2:04 pm

specialFolderPaths() docs (that I've found so far) indicate it should work for Linux, but I notice all the examples I keep seeing are for the other platforms. Is there a list of the subset of special paths that is supported on Linux?

specialFolderPaths("User") I would have expected to work even on Linux, but nothing so far; just returns empty string as with "documents".

specialFolderPaths("home") *does* return the home folder, so I can work with that, but I'm still curious: where is the documentation page I'm missing that lists specifically which special names work for this function in Linux?

Also, has anyone run into distribution idiosyncrasies on this particular function? I'm wondering if LXLE might be just different enough to throw off internal assumptions.

Klaus
Posts: 11113
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by Klaus » Fri Feb 08, 2019 2:09 pm

Hi slowmaker,

welcome to the forum!

It is spelled -> specialfolderpath() with no trailing S

Please scroll down to the bottom of the entry for "specialfolderpath" in the dictionary,
where you will magically find all supported specialfolderpath() codes for LINUX. :D
specialfolderpath("documents") is not supported on Linux, as you will see.


Best

Klaus

P.S.
A little "Hello" or something will surely not hurt for a first posting.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6791
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by FourthWorld » Fri Feb 08, 2019 3:49 pm

"~/Documents" will work.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

slowmaker
Posts: 13
Joined: Fri Feb 08, 2019 1:53 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by slowmaker » Fri Feb 08, 2019 4:21 pm

Thanks! Aggravatingly enough, I had read the same info -- twice -- in the documentation tab within the code editor, but had managed to scroll past the word Linux every time without catching it. I should pay more attention to the 'Less haste, more speed' adage.
Klaus wrote:
Fri Feb 08, 2019 2:09 pm
It is spelled -> specialfolderpath() with no trailing S
Yep, typo in the post; spelled it right in actual usage (otherwise the "home" call would presumably not have worked).
Klaus wrote:
Fri Feb 08, 2019 2:09 pm
A little "Hello" or something will surely not hurt for a first posting.
Hello!
Too late for first posting; does second post not-hurt less or more?

slowmaker
Posts: 13
Joined: Fri Feb 08, 2019 1:53 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by slowmaker » Fri Feb 08, 2019 4:32 pm

FourthWorld wrote:
Fri Feb 08, 2019 3:49 pm
"~/Documents" will work.
Not on mine so far. I'll have to play with it more later, thanks for the suggestion.

bogs
Posts: 3716
Joined: Sat Feb 25, 2017 10:45 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by bogs » Fri Feb 08, 2019 5:21 pm

Well, for sure
put specialfolderpath("Home") & "/Documents"
or
put specialfolderpath("Home") & "/Documents/"
will work :wink:

Play with those in the message box to get the feel of it.
Image

slowmaker
Posts: 13
Joined: Fri Feb 08, 2019 1:53 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by slowmaker » Fri Feb 08, 2019 6:41 pm

bogs wrote:
Fri Feb 08, 2019 5:21 pm
Well, for sure
put specialfolderpath("Home") & "/Documents"
or
put specialfolderpath("Home") & "/Documents/"
will work :wink:

Play with those in the message box to get the feel of it.
Nope. I should probably point out that I do not have a folder called Documents in my home folder. (mine is just "doc").

So hard-coded assumptions like that will not work.

I should also acknowledge *my* error of assumption: when FourthWorld suggested "~/Documents", I read too quickly and thought they meant to put that in as the argument to specialFolderPath(). I realize now they were probably suggesting I just hardcode it.

However, as noted above, that folder path assumption won't really work, because there are those of us, like me, who change their default docs folder.

What I was hoping for was that Livecode might have some magic going on that allowed it to query the system to find out what the default folders were set to. For instance, on ubuntu & co (like LXLE, the distro I use), one will have the option to call

Code: Select all

xdg-user-dir DOCUMENTS
and get the correct return value, even on a modded system like mine. The above returns /home/slowmaker/doc in my case.

This approach would work an anything using Freedesktop (you'll have to google it, the forum won't allow me to insert a link) utilities for that part of its setup. I don't know what percentage of Linux distros that would come to, though; could be this is one of those things that just varies too much to be reasonable for the livecode team to try to cover.

bogs
Posts: 3716
Joined: Sat Feb 25, 2017 10:45 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by bogs » Fri Feb 08, 2019 7:55 pm

slowmaker wrote:
Fri Feb 08, 2019 6:41 pm
What I was hoping for was that Livecode might have some magic going on that allowed it to query the system to find out what the default folders were set to. For instance, on ubuntu & co (like LXLE, the distro I use), one will have the option to call
[xdg-user-dir DOCUMENTS]
and get the correct return value, even on a modded system like mine. The above returns /home/slowmaker/doc in my case.
You *can* do that too :wink:
Selection_001.png
It is the old shell-game baby!
There are lots of ways to do what your looking to do, including using OS calls to accomplish your goals.
slowmaker wrote:
Fri Feb 08, 2019 6:41 pm
This approach would work an anything using Freedesktop (you'll have to google it, the forum won't allow me to insert a link) utilities for that part of its setup.
It will in 6 more posts for you :)
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6791
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by FourthWorld » Fri Feb 08, 2019 11:13 pm

slowmaker wrote:
Fri Feb 08, 2019 4:32 pm
FourthWorld wrote:
Fri Feb 08, 2019 3:49 pm
"~/Documents" will work.
Not on mine so far. I'll have to play with it more later, thanks for the suggestion.
Do you not have a Documents folder in your Home directory?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 3716
Joined: Sat Feb 25, 2017 10:45 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by bogs » Fri Feb 08, 2019 11:53 pm

FourthWorld wrote:
Fri Feb 08, 2019 11:13 pm
slowmaker wrote:
Fri Feb 08, 2019 4:32 pm
FourthWorld wrote:
Fri Feb 08, 2019 3:49 pm
"~/Documents" will work.
Not on mine so far. I'll have to play with it more later, thanks for the suggestion.
Do you not have a Documents folder in your Home directory?
slowmaker wrote:
Fri Feb 08, 2019 6:41 pm
Nope. I should probably point out that I do not have a folder called Documents in my home folder. (mine is just "doc").
Which is why I pointed out shell to slowmaker :)
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6791
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by FourthWorld » Sat Feb 09, 2019 5:19 am

No ~/Documents?

How would one use a function to get the path to a folder which does not exist?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

slowmaker
Posts: 13
Joined: Fri Feb 08, 2019 1:53 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by slowmaker » Sat Feb 09, 2019 1:11 pm

FourthWorld wrote:
Sat Feb 09, 2019 5:19 am
No ~/Documents?

How would one use a function to get the path to a folder which does not exist?
ah, but a folder designated as the-official-spot-for-documents *does* exist; it just happens to not be called Documents in some cases.

think of it as similar to the aims of specialFolderPath() itself; the point is to put in a generic name and get back a specific path which the system claims is used for the same purpose.

thus, calls to xdg-usr-dir can have returns like so:

Code: Select all

slowmaker@babybel:~$ xdg-user-dir USER
/home/slowmaker
slowmaker@babybel:~$ xdg-user-dir DOCUMENTS
/home/slowmaker/doc
slowmaker@babybel:~$ xdg-user-dir DOWNLOAD
/home/slowmaker/eval
slowmaker@babybel:~$ xdg-user-dir PICTURES
/home/slowmaker/pic
slowmaker@babybel:~$ xdg-user-dir VIDEOS
/home/slowmaker/vid
slowmaker@babybel:~$ xdg-user-dir MUSIC
/home/slowmaker/audio/music
The system 'knows' by way of config files (for Linux; Windows does it via registry entries, you can redirect standard Documents/Desktop/etc in Windows also). I assume Macs would do it similar to Linux, since they are based on Unix these days, but I don't know from personal experience.

A Linux distribution using FreeDesktop utilities would have a per user config file at ~/.config/user-dirs.dirs.
for example:

Code: Select all

slowmaker@babybel:~$ cat ~/.config/user-dirs.dirs
# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/desktop"
XDG_DOWNLOAD_DIR="$HOME/eval"
XDG_TEMPLATES_DIR="$HOME/templates"
XDG_PUBLICSHARE_DIR="$HOME/pub"
XDG_DOCUMENTS_DIR="$HOME/doc"
XDG_MUSIC_DIR="$HOME/audio/music"
XDG_PICTURES_DIR="$HOME/pic"
XDG_VIDEOS_DIR="$HOME/vid"
At some point this weekend I will bung together a wrapper function for specialFolderPaths() to add the missing magic needed to show (some segments of) Linux-land a little more love.

I'll post it here for future perusal by like-minded-oddballs; since I'm quite new to LiveCode syntax and coding conventions, I'm sure it will have rough edges that need sanding off. I would appreciate your input on that when the time comes.

(edited for typo)
(edited for phrasing; I realized the phrase 'like-me's' looked a bit like someone hungering for little gold stars stuck on their forehead! not what I intended, so I modified it a bit)

slowmaker
Posts: 13
Joined: Fri Feb 08, 2019 1:53 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by slowmaker » Sat Feb 09, 2019 2:21 pm

one more quick note on this, for others who may be interested in the internals of specialFolderPath():

I changed my desktop folder to just 'desk'. Afterward:

Code: Select all

slowmaker@babybel:~$ xdg-user-dir DESKTOP
/home/slowmaker/desk
but specialFolderPath("desktop"), running in the Message Box from a livecode session initiated from the same terminal instance as the above (and all this is after a reboot, just to be safe), still returns

Code: Select all

/home/slowmaker/Desktop
So for Linux, it appears (below is speculation based on behavior, I have no way of knowing the internals for sure):
specialFolderPath("desktop") = "$HOME/Desktop" -- not necessarily correct, just returning a hard-coded path.
specialFolderPath("user") = correct, probably checking $HOME for the "user" path
specialFolderPath("temporary") = "/tmp" -- another hard-coded path; this one is actually a fairly solid standard, as it is required by the Filesystem Hierarchy Standard of the Linux Foundation.

Gotta get to work now at actual paying job...

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6791
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by FourthWorld » Sun Feb 10, 2019 4:58 am

Thanks for the reminder about those FreeDesktop.org constants, slowmaker. I've filed a bug report on this:
https://quality.livecode.com/show_bug.cgi?id=21832
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

bogs
Posts: 3716
Joined: Sat Feb 25, 2017 10:45 pm

Re: specialFolderPaths("documents") returns empty string on linux LXLE

Post by bogs » Sun Feb 10, 2019 12:17 pm

FourthWorld wrote:
Sun Feb 10, 2019 4:58 am
Thanks for the reminder about those FreeDesktop.org constants, Bogs.
I think he means you, slowmaker :wink:
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”