Set Default Save location for Xed text editor

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
kanichiro
Level 2
Level 2
Posts: 93
Joined: Thu Nov 07, 2013 11:23 am
Location: Frostbite Falls, MN

Set Default Save location for Xed text editor

Post by kanichiro » Fri Aug 16, 2019 7:35 am

Is there a way to set the default "Save location" for the Xed text editor?

By default it goes to my Home folder. However, I prefer saving to my Desktop and moving the file to some where else if I wish. It would be much easier for me if when I saved a new Xed file that it defaulted to the Desktop.

I searched in these forums on Xed, but there were too many instances for the system to retrieve.

Thanks in advance!

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Set Default Save location for Xed text editor

Post by rene » Fri Aug 16, 2019 8:47 am

Said "default save location" is simply xed's default working directory and how to best change it (when started from the menu -- and possibly/probably from rightclick menu's and the like) is desktop dependent. On 19.2 Xfce, if I rightclick the Accesoires -> Text Editor and choose "Edit Application" entry I can edit the launcher's "Working Directory field to, e.g., /home/kanichiro/Desktop. I'm not currently near a Cinnamon system but if it or MATE does not provide a similar method, you can always manually do

Code: Select all

cp /usr/share/applications/xed.desktop ~/.local/share/applications/
and add e.g. "Path=/home/kanichiro/Desktop" to the end of ~/.local/share/applications/xed.desktop.

This of course does not work if you launch xed from the command line. For that you could create an executable wrapper script ~/bin/xed consisting of e.g.

Code: Select all

#!/bin/sh
[ $# -eq 0 ] && cd ~/Desktop
/usr/bin/xed $@
(be sure to chmod +x ~/bin/xed) so that simply xed from the command line would also change directory to ~/Desktop whereas e.g. xed foo.txt would not.

Given the question it seems likely you're mostly after the menu route though...

gm10
Level 20
Level 20
Posts: 10100
Joined: Thu Jun 21, 2018 5:11 pm

Re: Set Default Save location for Xed text editor

Post by gm10 » Fri Aug 16, 2019 8:53 am

The above solution has a number of issues. Instead copy & past all of this into a terminal window and run it:

Code: Select all

mkdir -p ~/.local/bin
tee ~/.local/bin/xed <<'EOB'
#!/bin/bash
CWD=$PWD/
cd $(xdg-user-dir DESKTOP)
case "$1" in
  ""|['/']*|'admin://'* ) CWD="";;
esac
/usr/bin/xed "$CWD$@"
EOB
chmod a+x ~/.local/bin/xed
You may have to log out and back in after this depending on whether you already had a ~/.local/bin folder.
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Set Default Save location for Xed text editor

Post by rene » Fri Aug 16, 2019 9:11 am

Rather misty why anyone would prefer a "hidden" ~/.local/bin over simply ~/bin... but other than that note that the first part of my reply above would be "nicer" if indeed you are not concerned with starting xed from the command line.

kanichiro
Level 2
Level 2
Posts: 93
Joined: Thu Nov 07, 2013 11:23 am
Location: Frostbite Falls, MN

Re: Set Default Save location for Xed text editor

Post by kanichiro » Sat Aug 17, 2019 6:56 am

I got it working as I wanted. Files now save to the desktop by default.

Thank you both for your help!

Kanichiro

User avatar
catweazel
Level 19
Level 19
Posts: 9805
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Set Default Save location for Xed text editor

Post by catweazel » Sat Aug 17, 2019 7:02 am

rene wrote:
Fri Aug 16, 2019 9:11 am
Rather misty why anyone would prefer a "hidden" ~/.local/bin over simply ~/bin...
Because it's tidier.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Set Default Save location for Xed text editor

Post by rene » Sat Aug 17, 2019 7:42 am

catweazel wrote:
Sat Aug 17, 2019 7:02 am
Because it's tidier.
Yeah. So is /.bin.

gm10
Level 20
Level 20
Posts: 10100
Joined: Thu Jun 21, 2018 5:11 pm

Re: Set Default Save location for Xed text editor

Post by gm10 » Sat Aug 17, 2019 7:50 am

rene wrote:
Sat Aug 17, 2019 7:42 am
catweazel wrote:
Sat Aug 17, 2019 7:02 am
Because it's tidier.
Yeah. So is /.bin.
Except /.bin is in no default path, so that wouldn't work at all without further modifications to the user's environment. Why try to reinvent the wheel? ~/.local/bin is the standard folder for things like this: https://www.freedesktop.org/software/sy ... local/bin/
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

User avatar
catweazel
Level 19
Level 19
Posts: 9805
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Set Default Save location for Xed text editor

Post by catweazel » Sat Aug 17, 2019 7:54 am

gm10 wrote:
Sat Aug 17, 2019 7:50 am
Except /.bin is in no default path, so that wouldn't work at all without further modifications to the user's environment. Why try to reinvent the wheel? ~/.local/bin is the standard folder for things like this: https://www.freedesktop.org/software/sy ... archy.html
Standards don't necessarily reflect aesthetics.

PS: Thanks for the tip about ~/.local/bin. I'll move my scripts there.

Cheers.
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Set Default Save location for Xed text editor

Post by rene » Sat Aug 17, 2019 8:23 am

gm10 wrote:
Sat Aug 17, 2019 7:50 am
~/.local/bin is the standard folder for things like this
A recent, paper, freedesktop and moreover, wrong standard, that comes after a couple of decades of ~/bin having been an actual real-world standard, alongside e.g. ~/lib, ~/tmp and so on, mirroring the regular, predictable UNIX directory structure in / and /usr. Most of those I still use to this day. Even foregoing history and/or tradition, it's still quite misty why anyone would want to create personal executables only to then hide them from oneself. But "because standard" is the reason, it seems. I sort of expect you willl at this point know where I'd advise anyone to stick this freedesktop "standard"...

gm10
Level 20
Level 20
Posts: 10100
Joined: Thu Jun 21, 2018 5:11 pm

Re: Set Default Save location for Xed text editor

Post by gm10 » Sat Aug 17, 2019 8:28 am

rene wrote:
Sat Aug 17, 2019 8:23 am
it's still quite misty why anyone would want to create personal executables only to then hide them from oneself.
:arrow:
catweazel wrote:
Sat Aug 17, 2019 7:02 am
Because it's tidier.
It's cool if you don't share that sentiment, ~/bin remains in the default path as well, so I don't even understand what you are arguing about...
Tune up your LM 19.x: ppa:gm10/linuxmint-tools

Post Reply

Return to “Software & Applications”