Tag: Linux

  • Persuading Scrivener (3.5.1) to use your folder names as chapter titles

    Because I’m either insane or a masochist, having got Scrivener working yesterday I decided I was going to import my document from word and then attempt to produce an epub. Since that’s essentially what Scrivener is for me, a glorified epub/book pdf producer, since they don’t support Linux properly, and also don’t support Android – and I do all my writing on those two OS’s.

    OTOH, there’s a dearth of ‘cuddly’ Linux tools to produce decent epubs and PDFs for printing, so… here we are.

    If you’re actually writing in Scrivener, this next bit you might want to skip.


    Now, before we get into this properly, I also should say my “import docx” process also was a pain in the arse. Despite the document having separate sections defined for each chapter, and each chapter having a heading, e.g. Chapter 1 – It’s Definitely Just a Game, it singularly failed to correctly divvy that up into chapters. What I ended up doing was running through that document and throwing a # in front of every chapter title and using the “import and split” function, but rather than use the default “Split using document’s outline structure”:

    Scrivener Import and Split window

    I selected “Split into sections by finding separators in the text”. The only problem with this is that for some reason it also picked up, seemingly only at the end of each chapter, the page number and included that in the text. So every chapter ended “Page nn”. I just fixed that by hand.

    Anyway, if you’ve actually written your document in Scrivener, that’s all kinda moot.


    Oookay.

    The recommended way to set up your books (although Scrivener are very much “you can do it how you like”) seems to be to have a folder for each chapter and then each scene in a separate Text. In my case because I imported a giant 120k word document, each chapter is one scene because I can’t be arsed to separate them.

    So you end up with something that looks a bit like this:

    Scrivener Main Window

    Now again, mine’s kinda funky because of the way I imported it. And my problem was that in my Text for each chapter, I had the chapter number and the title for the chapter and the subheadingy bit where I have the date (fractured timeline story, it hops about a lot). And what I wanted to do was have the chapter number and title as part of the Chapter Title, and then have the subheading-date as the Section Title.

    The solution to this would seem to be obvious. Change the Folder Name to the Chapter Title (in my case I just cut/pasted the Chapter Number and Title, but actually I’d probably suggest not doing it that way, and just putting the Title; y’know, in case you want to reorganise things in the future. I mean, my book is done apart from proofreading, so…hopefully it should now be fairly static).

    But then the epub that came out was…wrong. And finding the answer to “I would like my Folder names to be used as Chapter Names” turned out to involve a lot of wading through self righteous people explaining how you should read the manual and it’s all clear after that (it isn’t). And a lot of unanswered questions on multiple forums.

    So.

    The thing you need is indeed in the Compile Dialog. When you first open it it’ll probably look kinda like this – well, if you select “Compile for epub…” in the drop down menu at the top of the window:

    Scrivener Compile Dialog

    Now I’m going to recommend you go with this plan, so you don’t fuck up the original version, although it’s a bit more involved.


    But before we do that, when you click on ebook, if you get this error:

    Scrivener window with error

    Then you’ll need to cancel out of this dialog and go fix the assigned structure of your book. By default Scrivener sets this to “Structure Based” which I don’t yet know how it’s meant to work, but I can tell you it didn’t work for me.

    I had to go set all the folders to Chapter Heading but got away with leaving the individual Texts as Structure Based. If you collapse the tree so all you can see is the folders you can multiselect (Click on the first one and Shift-Click on the last one) and then right click and set them all in one go).

    By the way, a reminder, this is really me flying blind and throwing things at the wall until they stick. This worked for me, eventually.

     


    Okay, so back you go to that Compile window and select ebook. Then in one of the Section layouts (the middle section of the window), click on the little grey edity pen icon that appears when you hover around the corners of the example layouts.

    Then, for the sake of your sanity, click “Duplicate Format & Edit Layout”; I called mine “Ebook Titles from Folders” because I’m deeply imaginative.

    Compile dialog from Scrivener with Duplicate Format and Edit Selected clickedOnce that’s done you need the little grey button at the center bottom of the Compile window: Assign Section Layouts…

    Scrivener Assign Section LayoutsAnd then you need to assign a layout to each of the Section Types in the left hand pane. This is where it gets tricky, because I didn’t really understand what the examples were showing and it doesn’t provide a live example to show you based on how you’ve set things up. But my current understanding is that if you want your Folder Titles to be your chapter headings, you need to use Section Title. You can choose if you want a page break, or a border, or what have you. If you were wise enough not to hand-edit-in your chapter numbers, you might want a version that automatically inserts chapter numbers *and* a Section title, if that’s a thing you want.

    I ended up selecting Section Text for both Front Matter and Scene, and a Bordered Chapter Heading with Section Title for the contents for Chapter Heading:

    Section Layouts

    Obviously, if you want Back Matter, then you’ll also need to set that up. Since this was a ‘quick test’ I was doing to check that epub worked I’d thrown together a quick cover and used that.

    Anyhow, once you’ve done that, you can hit compile and you should end up with your folder titles as the chapter title…
    And thank fuck that’s done.

  • Scrivener 3.5.1 on Ubuntu Linux 22.04

    Scrivener seems like the best available option for epub production on Linux, so I decided to install it… There is a linked guide in the Scrivener forums (here) on which this is based, but Scrivener crashed twice during setup following it – several of the dialog boxes behaved very oddly – and when I got to the end of it I was presented with a black window that would, after a minute or so quit without doing anything. It took a bit of hunting around to work out why, and so here’s my version with the fixes I did.

    So, I’m going to basically nick the nice guide’s commands (because last time I didn’t do that, the guides then disappeared) – I’m not going to bother explaining the nice way the original author did, because you can read his nice post. He also has screenshots, because he’s a fancy duck. I’m not going to do that or install a VM to recreate the experience (because honestly, I can’t be bothered). Oh, and this is assuming you have an x86 based linux box*.

    I have presented this in more or less the order I did it – which is not the most efficient way to do this. I’ve tweaked it very slightly to avoid you running into Scrivener crashing during setup problem, but it’s pretty clear that you could fix skip installing the old version of Wine and hop straight to the new one. But since I didn’t test that I’m not going to put that as a “this works” set of instructions.

    Oh, and you’re gonna need a terminal window and some comfort with typing in commands.

    1. Download Scrivener for Windows 64 bit version (3.5.1 is the version I have working).

    Okay, fire up your terminal window and go to town:

    1. Enable i386 architecture

      sudo dpkg --add-architecture i386

    2. Update your sources

      sudo apt-get update

    3. Install Wine and some other dependencies

      sudo apt-get install winetricks wine64 wine32:i386 winbind -y


    Okay… now here’s where I’m going to recommend that you do things slightly differently than I did. Because here I proceeded to “Installing Scrivener” and then ran into problems. I’m not willing uninstall it to test the theory that this order works better, nor do I want to spend the time to create a VM to test this theory. But I present to you the two options:

    • Following the semi-official instructions, go through the flaky – crashes multiple times – setup which worked for me after doing steps 5-7 to fix its not-working state. If you wanna do that, do steps 8-11 and then come back and do 5-7 if it doesn’t work.

    Or

    • Do these steps 5-6 first, then install Scrivener. This should skip the crashing during setup issues I had, and the well this doesn’t work disappointment of the official instructions. I have not tested this option, but it’s what I’d do knowing what I do now. YMMV.

    1. Upgrade Wine – Wine in the Ubuntu repositories is ooold, and a more modern version seems to be required for Scrivener to work now. This requires a few steps:
      • Install more required packages to allow WineHQ’s own version to install. You could probably merge this with step 4.

        sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl -y

      • Add the WineHQ repository to your list of approved places to get software from

        curl -s https://dl.winehq.org/wine-builds/winehq.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/winehq.gpg > /dev/null

      • Import that repository that you just added

        echo deb [signed-by=/usr/share/keyrings/winehq.gpg] http://dl.winehq.org/wine-builds/ubuntu/ jammy main | sudo tee /etc/apt/sources.list.d/winehq.list

      • Update your sources

        sudo apt-get update

      • Install the new shiny version of Wine over the top of your archaic one

        sudo apt install winehq-stable --install-recommends

      • You can check this worked with the command

        wine --version

        Which on my system today says Wine 9.0

    2. Upgrade Winetricks

      sudo winetricks --self-update

    3. Now while Scrivener will/should work on Windows 7, which is how Wine likes to present itself by default, it works better on Windows 10. It also requires dotnet to activate the licence, apparently. I’m still using the test version. BTW, Firing off this command will present you with a bunch of Windows installs to run through and should tell wine to identify itself as Windows 10.

      winetricks --force corefonts win10 dotnet48

    Okay. Now you’ve put in all the prerequisites, you can install and setting up Scrivener:

    1. Run the Scrivener installer in Wine – Ryan recommends moving the default install location to C:/Scrivener for ease of use. And don’t let it install desktop icons (they won’t work).

      wine ~/Downloads/Scrivener-installer.exe

    2. Delete Scrivener’s own Text to speech. It’s broken and causes the application to hang in Wine.

      cd ~/.wine/drive_c/scrivener

      rm -rf texttospeech/

    3. Create a script in your home directory to fire up Scrivener so you don’t have to type out the long command each time (Ryan recommends using vi. I’m not going to do that to you; if you’re happy using vi go ahead, but it’s not exactly friendly to people who might be at the level of needing this guide).

      cd ~

      nano scriv.sh

      • Type this into the first line in your nice empty text file:

        cd ~/.wine/drive_c/scrivener && /usr/bin/wine Scrivener.exe

      • Hit [Ctrl+O] to save
      • Hit [Ctril+X] to exit
    4. Make your shiny new script executable (a thing you can run as a program)

      chmod 0700 scriv.sh

    Now from your command line if you type ./scriv.sh you should have Scrivener working.

    Feel free to tell me if you don’t. Don’t expect me to fix it…

    * If you don’t know what x86 means, as long as it’s a ‘proper laptop’ and doesn’t have an apple logo on it you’re probably fine. If you’re trying to do this on a repurposed chromebook, ???? ????? (?Allah yahfazak). Theoretically, I think you could get this working on an ARM/apple silicon based linux box using QEMU. When my MNT Pocket Reform arrives I may do that, just for shits and giggles. If I do I’m sure I’ll do another high quality guide like this.

  • I just laid my hands on a Squeezebox 2 (actually two, but one of them’s dead, this one just the WiFi card is dead). It’s quite delightful. As in, gleeful clapping of hands as I went ‘No, play that’ on my laptop and it went

    “Yes Mistress”

    Then I tapped around on the remote and went, ‘no, play that’ and it went 

    “Yes m’lady”

    And so far no hassle. Yeah, my messy fileserver’s led to some interesting track titles, but when I eventually sort this out (ha) then it should be quite perfect.

    Now I just need to get the other one working.