Linux: Difference between revisions

From Wiki
m (Change image position for GoldenDict)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
== General ==
Subpages
 
<splist sortby="title" liststyle="unordered" showpath="no" kidsonly="no" debug="0" />
 
 
==General==
 
===Offline dictionary ===
 
==== Golden Dict with WordNet 3.0 ====


=== Offline dictionary - GoldenDict ===
[[File:GoldenDict-rescan-dictionaries.png|thumb]]
[[File:GoldenDict-rescan-dictionaries.png|thumb]]
Install the [[wikipedia:GoldenDict|GoldenDict]] dictionary application for your Linux distribution.
Install the [[wikipedia:GoldenDict|GoldenDict]] dictionary application for your Linux distribution.
Line 7: Line 15:
By default, the application only seems to use online dictionaries for English to English dictionaries.
By default, the application only seems to use online dictionaries for English to English dictionaries.


Download the free offline dictionary Wordnet3 from [https://osdn.net/projects/sfnet_goldendict/downloads/dictionaries/WordNet3.0_1.0.zip/ here].
Download the free offline dictionary Wordnet3 from [http://downloads.sourceforge.net/goldendict/WordNet3.0_1.0.zip here].


Unzip the downloaded file and place the file that ends with .dz in /usr/share/dictd
Unzip the downloaded file and place the file that ends with .dz in /usr/share/goldendict


Now open GoldenDict. Go to Edit -> Dictionaries (or press F3). Under the Sources -> Files, you'll see the directories that GoldenDict looks for dictionary files. Press the "Rescan now" button in the right pane to index the newly added dictionary.
Now open GoldenDict. Go to Edit -> Dictionaries (or press F3). Under the Sources -> Files, you'll see the directories that GoldenDict looks for dictionary files. Use the "Add" button if /usr/share/goldendict is not on the path. Press the "Rescan now" button in the right pane to index the newly added dictionary.


''Optional:'' You can also make WordNet3 the dictionary with the highest priority by dragging it to the top in the ''Dictionaries'' tab.
''Optional:'' You can also make WordNet3 the dictionary with the highest priority by dragging it to the top in the ''Dictionaries'' tab.


== Network Tricks ==
==Network Tricks==


=== Connecting to two networks - one Wi-Fi and one wired ===
===Connecting to two networks - one Wi-Fi and one wired===


Wi-Fi network has internet, wired does not. Then, disable the gateway of the Wired network for internet access.
Wi-Fi network has internet, wired does not. Then, disable the gateway of the Wired network for internet access.
Line 33: Line 41:
<code>$ sudo ip route del default via 192.168.1.1</code>
<code>$ sudo ip route del default via 192.168.1.1</code>


=== chroot into a Raspberry Pi ===
==Gnome tricks==


==== Mount sequence ====
===Creating a desktop launcher on Gnome===


Install '''gnome-panel'''
<pre>
<pre>
mount /dev/sdb3 /mnt
sudo apt-get install --no-install-recommends gnome-panel
mount /dev/sdb2 /mnt/boot
mount /dev/sdb1 /mnt/boot/firmware
mount -o bind /proc /mnt/proc
mount -o bind /sys /mnt/sys
mount -o bind /dev /mnt/dev
mount -o bind /dev/pts /mnt/dev/pts
cp /usr/bin/qemu-arm-static /mnt/usr/bin
chroot /mnt
</pre>
</pre>


==== Doing stuff in chroot ====
'''Example:''' Fixing a broken apt install


Open the '''Create Launcher''' dialog and enter the details for the launcher
<pre>
<pre>
dpkg --configure -a
sudo gnome-desktop-item-edit --create-new /usr/share/applications
apt -f install
exit
</pre>
</pre>


==== Unmount sequence ====
Done.


<pre>
<br />
umount /mnt/dev/pts
 
umount /mnt/dev/
=== Reset Gnome configuration ===
umount /mnt/sys
Run this command as your user
umount /mnt/proc
umount /mnt/boot/firmware
umount /mnt/boot/
umount /mnt
</pre>


== Gnome tricks ==
<code>dconf reset -f /org/gnome/</code>


=== Creating a desktop launcher on Gnome ===
Logout and login.
==Video Editing==


Install '''gnome-panel'''
===Trimming a video===
<pre>
sudo apt-get install --no-install-recommends gnome-panel
</pre>


ffmpeg can be used to quickly trim a video from a given start time to end time.


Open the '''Create Launcher''' dialog and enter the details for the launcher
<pre>
<pre>
sudo gnome-desktop-item-edit --create-new /usr/share/applications
ffmpeg -i video.webm -ss 00:00:00 -t 00:05:04 -c copy video-cut.webm
</pre>
</pre>


Done.
ss and t can be skipped in case of start of video or end of video respectively. The same works for mp3 files.
 
See [https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg/11175851#11175851 this] for joining videos.


=== Trimming a video ===
== PDF Editing ==
Using PDF toolkit on Debian to merge or split PDF files - http://net2.com/how-to-install-and-use-pdftk-on-linux-to-merge-or-split-pdf-files/


ffmpeg can be used to trim a video from a given start time to end time.
pdfsam is another alternative which I didn't use.


<pre>
==Ebooks==
ffmpeg -i video.webm -ss 00:00:00 -t 00:05:04 -async 1 video-cut.webm
</pre>


== Create ebook from a website using Calibre ==
===Create ebook from a website using Calibre===


Some free books on the internet are available as HTML pages. <br>
Some free books on the internet are available as HTML pages. <br>
Line 103: Line 94:


<pre>
<pre>
wget -r --no-parent http://www.hpmor.com/
wget -r --no-parent -erobots=off http://www.hpmor.com/
ebook-convert index.html hpmor.epub
ebook-convert index.html hpmor.epub
</pre>
</pre>


== X Window system tricks ==
=== Convert ebook to audiobook ===
I wrote a [https://book.babashka.org/ babashka] script for this: [https://njoseph.me/gitweb/babashka-scripts.git/blob/HEAD:/ebook-to-audio-book ebook-to-audiobook]


=== Switch to Colemak layout in X window system ===
==X Window system tricks==
 
===Switch to Colemak layout in X window system===
<pre>
<pre>
setxkbmap us -variant colemak
setxkbmap us -variant colemak
</pre>
</pre>


=== Natural scrolling ===
===Natural scrolling===
Run the following command, then logout and login.
Run the following command, then logout and login.
<pre>
<pre>
Line 120: Line 114:
</pre>
</pre>


== VirtualBox tricks ==
==VirtualBox tricks==
 
===Adding a new virtual USB disk to a virtual machine===
 
*Enable USB controller for the virtual machine. This can be done from the VirtualBox UI.
*Create a new virtual disk and add it using the USB controller.
*Run this command as root inside the box.


=== Adding a new virtual USB disk to a virtual machine ===
* Enable USB controller for the virtual machine. This can be done from the VirtualBox UI.
* Create a new virtual disk and add it using the USB controller.
* Run this command as root inside the box.
     # mkfs.ext4 /dev/sdb
     # mkfs.ext4 /dev/sdb
==GPG and Thunderbird==
To renew an expired GPG primary key,
<pre>
gpg --edit-keys <key-id>
>>> expire
1y
>>> save
</pre>
For subkeys, you have to first enter the key number like "key 1"
Send the updated keys to several keyservers
<pre>
gpg --keyserver keyserver.ubuntu.com --send-keys <key-id>
gpg --keyserver pgp.mit.edu --send-keys <key-id>
</pre>
Export the secret key to a file.
<pre>
gpg --output private.gpg --armor --export-secret-key <key-id>
</pre>
In Thunderbird, open PGP Key Manager and import the new key.
Delete the above secret key file.

Latest revision as of 20:15, 20 March 2024

Subpages


General

Offline dictionary

Golden Dict with WordNet 3.0

GoldenDict-rescan-dictionaries.png

Install the GoldenDict dictionary application for your Linux distribution.

By default, the application only seems to use online dictionaries for English to English dictionaries.

Download the free offline dictionary Wordnet3 from here.

Unzip the downloaded file and place the file that ends with .dz in /usr/share/goldendict

Now open GoldenDict. Go to Edit -> Dictionaries (or press F3). Under the Sources -> Files, you'll see the directories that GoldenDict looks for dictionary files. Use the "Add" button if /usr/share/goldendict is not on the path. Press the "Rescan now" button in the right pane to index the newly added dictionary.

Optional: You can also make WordNet3 the dictionary with the highest priority by dragging it to the top in the Dictionaries tab.

Network Tricks

Connecting to two networks - one Wi-Fi and one wired

Wi-Fi network has internet, wired does not. Then, disable the gateway of the Wired network for internet access.


Show the networks

$ ip route show

Smaller metric number means higher priority for the gateway


Remove the gateway of the wired network

$ sudo ip route del default via 192.168.1.1

Gnome tricks

Creating a desktop launcher on Gnome

Install gnome-panel

sudo apt-get install --no-install-recommends gnome-panel


Open the Create Launcher dialog and enter the details for the launcher

sudo gnome-desktop-item-edit --create-new /usr/share/applications

Done.


Reset Gnome configuration

Run this command as your user

dconf reset -f /org/gnome/

Logout and login.

Video Editing

Trimming a video

ffmpeg can be used to quickly trim a video from a given start time to end time.

ffmpeg -i video.webm -ss 00:00:00 -t 00:05:04 -c copy video-cut.webm

ss and t can be skipped in case of start of video or end of video respectively. The same works for mp3 files.

See this for joining videos.

PDF Editing

Using PDF toolkit on Debian to merge or split PDF files - http://net2.com/how-to-install-and-use-pdftk-on-linux-to-merge-or-split-pdf-files/

pdfsam is another alternative which I didn't use.

Ebooks

Create ebook from a website using Calibre

Some free books on the internet are available as HTML pages.
An epub file is simply an archive of HTML pages that can be treated as an ebook.
A book website can be stitched into an ebook using wget and calibre

wget -r --no-parent -erobots=off http://www.hpmor.com/
ebook-convert index.html hpmor.epub

Convert ebook to audiobook

I wrote a babashka script for this: ebook-to-audiobook

X Window system tricks

Switch to Colemak layout in X window system

setxkbmap us -variant colemak

Natural scrolling

Run the following command, then logout and login.

echo "pointer = 1 2 3 5 4 6 7 8 9 10 11 12" >> ~/.Xmodmap

VirtualBox tricks

Adding a new virtual USB disk to a virtual machine

  • Enable USB controller for the virtual machine. This can be done from the VirtualBox UI.
  • Create a new virtual disk and add it using the USB controller.
  • Run this command as root inside the box.
   # mkfs.ext4 /dev/sdb

GPG and Thunderbird

To renew an expired GPG primary key,

gpg --edit-keys <key-id>
>>> expire
1y
>>> save

For subkeys, you have to first enter the key number like "key 1"

Send the updated keys to several keyservers

gpg --keyserver keyserver.ubuntu.com --send-keys <key-id>
gpg --keyserver pgp.mit.edu --send-keys <key-id>

Export the secret key to a file.

gpg --output private.gpg --armor --export-secret-key <key-id>

In Thunderbird, open PGP Key Manager and import the new key. Delete the above secret key file.