Kubuntu : Add new swap

Version of Kubuntu : 18.04

First check the status of the swap

swapon --show

	NAME       TYPE SIZE USED PRIO
	/swapfile file   8G 7,7G   -2

display information about the current state of the swap

From here create a new swap file with an other name

sudo fallocate -l 16G /swapfile2
sudo chmod 600 /swapfile2
sudo mkswap /swapfile2

Create a new swapfile

And activate it

sudo swapon /swapfile2
sudo vim /etc/fstab

Activate the new swap

/swapfile2 none swap sw 0 0

add this line to /etc/fstab

You should not have to restart your system

Remove the old swap

First deactivate your old swap (this can take some time !)

sudo swapoff /swapfile

Deactivate the old swap

Then delete the old swap file

sudo rm -rf /swapfile

Change changes in the for future

sudo vim /etc/fstab

edit the file system table and remove the reference to the old swap

Kubuntu : use mouse shortcuts

Version of Kubuntu : 18.04

Guide to setup mouse shortcuts to control the UI on Kubuntu.

Prerequisites

Install xbindkeys and qdbus

sudo apt-get install xbindkeys
sudo apt-get install qdbus

Create a default xbindkeys config file

xbindkeys --defaults-guile > /home/<HOME_FOLDER>/.xbindkeysrc.scm

Which mouse event

To get the mous events description you can use the xev utilities

xev | grep button

You will get output like

    state 0x10, button 1, same_screen YES
    state 0x110, button 1, same_screen YES
    state 0x10, button 8, same_screen YES
    state 0x10, button 8, same_screen YES
    state 0x10, button 9, same_screen YES
    state 0x10, button 9, same_screen YES
    state 0x10, button 10, same_screen YES
    state 0x10, button 10, same_screen YES

the corresponding events will be b:1 for button 1, b:10 for button 10 etc…

Which script

Get a full list of the KDE Kwin desktop shortcut with

qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.shortcutNames

they are to be used with the command (you can try them in the terminal)

qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut "<YOUR SHORTCUT>"

Stitch all of that into shortcut

Edit the .xbindkeysrc.scm file that we created earlier with your prefered editor

v ~/.xbindkeysrc.scm
(xbindkey '(Control "b:9") "/home/<HOME_FOLDER>/Documents/dev/conf/scripts/ctrl_mouse_arrow_next.sh")
(xbindkey '(Control "b:8") "/home/<HOME_FOLDER>/Documents/dev/conf/scripts/ctrl_mouse_arrow_previous.sh")

(xbindkey '("b:10") "/home/sephah/<HOME_FOLDER>/dev/conf/scripts/mouse_thumb.sh")
(xbindkey '(Control "b:10") "/home/<HOME_FOLDER>/Documents/dev/conf/scripts/ctrl_mouse_thumb.sh")
(xbindkey '("b:13") "/home/<HOME_FOLDER>/Documents/dev/conf/scripts/mouse_zoom.sh")

Here is the content of those files

WARNING : DO NOT FORGET TO MAKE THEM EXECUTABLE

#!/bin/bash

# Loop through the x axis of windows
qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Switch One Desktop to the Right'

# Or use "go to next desktop"
# qdbus org.kde.KWin /KWin nextDesktop

ctrl_mouse_arrow_next.sh

#!/bin/bash

# Loop through the y axis of windows
qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut 'Switch One Desktop Up'

# Or use "go to previous desktop"
# qdbus org.kde.KWin /KWin previousDesktop

ctrl_mouse_arrow_previous.sh

#!/bin/bash

# key binding to Control F8
# Which is binded to show all desktops
xte 'keydown Control_L' 'key F8' 'keyup Control_L'

ctrl_mouse_thumb.sh

#!/bin/bash

# Show all app "Expose" style (like in mac)
qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut Expose

mouse_thumb.sh

#!/bin/bash

# Show desktop script
# ref : https://askubuntu.com/a/399280

current_mode="$(wmctrl -m | grep 'showing the desktop')"

if [[ "${current_mode##* }" == ON ]]; then
    wmctrl -k off
else
    wmctrl -k on
fi

mouse_zoom.sh

Start the script

With the command :

xbindkeys
# Or if you already started the xbindkey and want to update the key bidings
killall xbindkeys && xbindkeys

References

Some inspiration for xbindkeys : https://pryp.in/blog/19/zoom-the-screen-with-alt-scroll-in-kde.html

The script for “showing desktop” : https://askubuntu.com/a/399280

More shortcut ideas and xev command : https://blog.hanschen.org/2009/10/13/mouse-shortcuts-with-xbindkeys/

Improve it

Shortcut for zoom : https://bbs.archlinux.org/viewtopic.php?id=106494

More shortcut ideas : https://martinovic.blog/post/kdeconnect_commands/

Other idea for looping through desktops : https://www.reddit.com/r/kde/comments/8h92z0/command_line_command_to_switch_virtual_desktop/