![]() |
#1 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
any interest in an *-env.txt file for setting env vars for Sigil
Hi All,
Given how much effort and how messy it is to set environment variables for macOS that actually get read when launching Sigil from the Finder or Panel or Drag and Drop, I have decided to borrow a page out of Kovid's calibre for macOS that enables a macos-env.txt file. This file would be kept in Sigil's Preferences folder and the user could use any text editor to set environment variables for use inside of Sigil that would be read by Sigil on startup. The format is (one per line): ENVIRONMENT_VARIABLE_NAME=VALUE I have tested this and it seems to work well. My question is do we want to make this feature available to all platforms? Maybe with a win-env.txt, or a linux-env.txt (or unix-env.txt) so that any user on any platform could use any text editor to set and change Sigil environment variables? If so, this would be an easy change. Thoughts? Last edited by KevinH; 08-18-2025 at 10:00 PM. |
![]() |
![]() |
![]() |
#2 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 451
Karma: 3886916
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Kobo Forma
|
I'm using Linux, and that would be very nice. I would use it.
|
![]() |
![]() |
![]() |
#3 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,845
Karma: 169712582
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
I agree that it would be a nice feature.
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,677
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I say yes for Windows, too.
|
![]() |
![]() |
![]() |
#5 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
Okay, I will tweak that routine to work on all platforms and push it to master.
|
![]() |
![]() |
![]() |
#6 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
One other question ... Does or even can anyone ever share the same Sigil Prefs folder across platforms?
If not, then instead of platform specific file name like macos-env.txt, win-env.txt, etc, can we use just one file name like "env-vars.txt" for all platforms? It will make the code have fewer ifdefs. |
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,677
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I sure don't. I've never even tried it. I say keep it simple.
|
![]() |
![]() |
![]() |
#8 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
Okay, that is what I did, so no ifdefs at all!
It uses one text file called "env-vars.txt" inside the root of the Sigil Preferences folder. I modified it to use Utility::ReadUnicodeTextFile() so it should be able to automatically handle native Windows utf-16 text files as well as normal utf-8 text files, and should handle removing any BOM markers so nothing should interfere. The format is (one per line): ENVIRONMENT_VARIABLE_NAME=VALUE both are treated as strings that are trimmed so no quotes are needed anyplace. I tried to make this happen as early as possible after main() so that even Qt and Chrome EVs can be set into the env-vars.txt file properly. Note, that means this file is only read once on first startup of Sigil. I have just pushed this to master. I will update the sigil-user-guide to reflect how this env-vars.txt can be used to make setting environment variables easier for everyone in the advanced topics chapter that lists all of our environment variables. If anyone builds their own and uses Sigil or Qt/Chrome env vars, please give it a try and let me know if any issues happen. Thanks Update: I pushed the Sigil User Guide updates to its master. It will be ready when we do our next release (ie. 2.6.2) sometime down the road. Last edited by KevinH; 08-19-2025 at 12:29 PM. |
![]() |
![]() |
![]() |
#9 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,677
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Great! This will come in handy for people who don't know how to set an environment variable. It will also ensure they don't have to set variables that could affect other programs without needing to create scripts to set variables and launch programs. I'm pretty sure QTextStream and QString both convert all line endings to \n in memory, right? No need to worry about \r\n.
Correct me if I'm wrong, but couldn't this approach also solve the custom .bdic location for PageEdit problem that we were discussing? Set the variable in the file and drop/copy dictionaries where you want? Something in your recent pushes is failing the Linux CI build on GitHub (which uses our Python and Qt minimums), however. |
![]() |
![]() |
![]() |
#10 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,115
Karma: 60406498
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#11 | |||
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
Quote:
Quote:
Quote:
Last edited by KevinH; 08-19-2025 at 12:59 PM. |
|||
![]() |
![]() |
![]() |
#12 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
|
![]() |
![]() |
![]() |
#13 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
Okay, it seems in Qt 6.4 and earlier, QDebug"s << operator did not understand std::strings. In later Qt versions that ability to work with std::strings was added. So I literally just had to add a static QString::fromStdString to convert it and old Qt QDebug is now happy.
So we should be good to go. Your minimum requirements Linux CI is really nice as it forces me to be honest! |
![]() |
![]() |
![]() |
#14 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,677
Karma: 205039118
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Looks good! I don't know why I never thought of this sooner, but I'm updating the various CI builds to be able to be kick-started (and deployed) manually. Like we can do with the Linux AppImage CI. It's silly for us to have wait on 5 separate processes (not to mention sometimes having to do a pointless commit just to add [deploy] to the message) when we might want to just generate a beta installer based on the most recent commits.
Testing on Windows now. If all goes well, I'll add the same ability to the two macOS workflows. |
![]() |
![]() |
![]() |
#15 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,873
Karma: 6120478
Join Date: Nov 2009
Device: many
|
If anyone tries this with their own builds, please regrab from Sigil master now as my move to all platforms introduced a bug that has now been fixed.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
sigil does'nt load txt-files | ikkethuis | Sigil | 1 | 01-11-2021 01:46 PM |
Filename to File Tag and Setting File Dorectory | anonymust | Library Management | 3 | 11-07-2015 07:42 PM |
shebang problem "/usr/bin/env python2" | klonuo | Development | 2 | 10-21-2011 11:08 AM |
How can i convert HTML or txt file to EPUB file ? | guguqiaqia | ePub | 7 | 05-28-2010 09:15 PM |
Problem & fix to Windows dev env setup | ShellShock | Calibre | 6 | 12-07-2008 10:13 AM |