I would like to automate e-book build from remote repositories. A command-line tool would be useful in this case. Is there any software for Ubuntu?
Ubuntu – ny command-line software to create e-books from the scratch in Ubuntu
16.04command lineebooks
Related Solutions
Short Version:
Find the Exec command for your app by grepping the applications directory
grep 'Calculator' /usr/share/applications/*
Start the app
gcalctool
Kill it by hitting Ctrl+C
First, find out where your application is. A few directories are in an environment variable $PATH
, so that you don't have to type the whole directory.
One way to find your app is to open the Menu Editor (right click on the Applications Menu and select Edit Menus) and find the app's command.
The calculator, for example is gcalctool
at /usr/bin/gcalctool
(use the whereis
command to find the exact path of an app). Since /usr/bin
is in the PATH variable (type echo $PATH
), you can run it in your terminal by typing gcalctool
.
It's now running in the foreground. You can pause it by pressing Ctrl+Z, resume it in the background by typing bg
,or resume it in the foreground by typing fg
. You can also use fg
to raise an app to the foreground.
If you do this with multiple apps, you can use jobs
to get a numbered list of all of them, and then use, for example, fg 3
to raise one of them.
An App that is in the foreground can be killed with Ctrl+C or Ctrl+\ (if it doesn't react to the former).
A universal way to find your app is to open the File Browser, go to Filesystem → usr → share → applications and to find your app there.
You'll see a bunch of .desktop
files, which you can drag into a Text Editor (or use cat
) to read. This is a piece of the Calculators .desktop file:
[Desktop Entry]
Name=Calculator
Comment=Perform arithmetic, scientific or financial calculations
Exec=gcalctool
The Exec entry is what you're interested in here. It's the same you would see if you went to the Menu Editor, just quicker. You can grep the files to search them for your app, if you can't find it.
If the app doesn't have a .desktop file in the applications directory, you have to know it's command of course. Use TAB to get suggestions from just a few letters. Press tab, tab, y to get a huge list of every application.
Even a simpler script to toggle between activating or deactivating a particular ppa. Save the code given below in a file, for instance toggle_ppa.sh
.
#!/bin/bash
#
# toggle_ppa.sh
#
# created by souravc (https://askubuntu.com/users/127327/)
# modified by Glutanimate (https://askubuntu.com/users/81372/)
#
# originally released at https://askubuntu.com/q/383605/81372
#
# DESCRIPTION: Detects if a PPA is active/inactive and deactivates/activates it
# on user confirmation.
#
# USAGE: toggle_ppa.sh ppa:launchpaduser/ppaname
### VARIABLES
SOURCEDIRECTORY=/etc/apt/sources.list.d
PPA="$1"
### USAGE CHECKS
## Arguments
if [ -z "$PPA" ]
then
echo "Error: Please provide a PPA name to toggle between activation/deactivation"
echo "The PPA name should be formatted as it appears on launchpad, e.g.:
"$0" ppa:webupd8team/y-ppa-manager"
exit 1
fi
## Root privileges
if [ "$(whoami)" != "root" ]; then
echo "Error: This script needs root privileges. Restarting..."
sudo "$0" "$1"
exit
fi
### MAIN
SOURCELIST_NOPFX="${PPA#*:}" #remove 'ppa:' prefix
SOURCELIST="${SOURCELIST_NOPFX////-}"-$(lsb_release -cs) #replace all slashes with dashes, include release
SOURCEFILE="$SOURCEDIRECTORY"/"$SOURCELIST".list #compose sources list path
if [ -e "$SOURCEFILE" ]
then
echo "Processing $SOURCEFILE..."
SOURCE_COMMENTED=$(grep "^\#deb\ " "$SOURCEFILE") #check if sources line is commented
if [ -z "$SOURCE_COMMENTED" ]
then
echo "$PPA is active. Going to deactivate. Proceed? [ y/n ]"
read ANSWER
if [ $ANSWER == "y" ]
then
sed -i "s/^deb\-src/\#deb\-src/" $SOURCEFILE
sed -i "s/^deb\ http/\#deb\ http/" $SOURCEFILE
echo "Updating package index files..."
sudo apt-get update
echo "Done."
else
echo "Aborted."
exit 0
fi
else
echo "$PPA is inactive. Going to activate. Proceed? [ y/n ]"
read ANSWER
if [ $ANSWER == "y" ]
then
sed -i "s/^\#deb\-src/deb\-src/" $SOURCEFILE
sed -i "s/^\#deb\ http/deb\ http/" $SOURCEFILE
echo "Updating package index files..."
sudo apt-get update
echo "Done."
else
echo "Aborted."
exit 0
fi
fi
else
echo "Error: Source file at $SOURCEFILE for $PPA does not exist. Please check PPA name."
exit 0
fi
Follow the procedure given at the other answer to keep file in PATH and make it executable.
Usage
sudo toggle_ppa.sh <full-ppa-name>
Example
sudo toggle_ppa.sh ppa:webupd8team/java
How it works
The working principle of this code is the same as in my other answer. The code acts in a very interactive manner. When someone runs this along with ppa name as its argument, it will display the PPA's current status and what the code is going to do on successful execution. Then it will ask permission of the user. Only if the user inputs 'y'
to confirm the code will change the status of the PPA and activate/deactivate it. It will immediately abort if the user puts an 'n'
for no.
Best Answer
A wide variety of documents can be converted to ebook (epub, mobi, ...) using
ebook-convert
which is part of thecalibre
package.For example, as long as
input
is a supported format, anepub
can be created with the command:Or, if you use kindles:
Some input formats include: LIT, MOBI, AZW, EPUB, AZW3, FB2, DOCX, HTML, PRC, ODT, RTF, PDB, TXT, PDF.
If the input file is a PDF, then one may want to add an option:
Calibre may be available from your package manager but it often helps to install the latest version which is available here.
Authoring a book
As an alternative to calibre, OpenOffice/LibreOffice offers an extension, Writer2ePub, to claims to be able to create "well formatted, easy readable ePub" files with a single click.
The Writer2ePub extension can be downloaded from here.