samedi 5 janvier 2019

how to remap key less than "<" greater that ">" on hp laptop omen (linux / gnome / arch) ?

- install xorg-xev: sudo pacman -S xorg-xev
- run xev
- in the window press the key you want to remap and look in the terminal what's the value for "keycode" (for me it was keycode=105)

KeyPress event, serial 34, synthetic NO, window 0x3e00001,
    root 0x167, subw 0x0, time 396542, (376,252), root:(459,402),
    state 0x10, keycode 105 (keysym 0x3c, less), same_screen YES,
    XKeysymToKeycode returns keycode: 94
    XLookupString gives 1 bytes: (3c) "<"
    XmbLookupString gives 1 bytes: (3c) "<"
    XFilterEvent returns: False

- now if you want less than "<" and greater that ">" holding shift, you have to use this command:
xmodmap -e "keycode 105 = less greater less greater bar brokenbar lessthanequal greaterthanequal"

- this change is only available during the user's session, after a restart you'd have to type it again.

- if like me you're using Gnome 3 (gnome-shell) you should add a new .desktop file in ~/.config/autostart to execute a script containing the command at each startup of the gnome session.
- for example create ~/scripts/keyboardRemapKey.sh with
#!/bin/bash
xmodmap -e "keycode 105 = less greater less greater bar brokenbar lessthanequal greaterthanequal"

- then create ~/.config/autostart/keyboardRemapKey.desktop with
[Desktop Entry]
Name=Keyboard remap
GenericName=Keyboard remap "less key" at startup
Comment=Keyboard remap "less key" at startup
Exec=/home/user/scripts/keyboardRemapLessKeyAtStartup.sh
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

and the change will be permanent.

//TODO: add some config files in
https://www.freedesktop.org/wiki/Software/XKeyboardConfig/Development/
https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Config.html
https://michal.kosmulski.org/computing/articles/custom-keyboard-layouts-xkb.html

mardi 1 janvier 2019

how to add a new environment variable to PATH on ARCH/Debian/Ubuntu?

The global variable PATH is set up in /etc/profile.
What we want is to override this PATH variable's value with the new variable at the user level.
User variable configuration file is ~/.bashrc, so edit this file with your favorite editor:

at the end of the file add a line with your new variable declaration:

#my new variable
export MY_NEW_EXECUTABLE_HOME_DIR=/home/user/libs/myNewLib

then override the globally declared PATH variable like this:
export PATH="${PATH}:$MY_NEW_EXECUTABLE_HOME_DIR/bin"



jeudi 6 septembre 2018

mercredi 27 juin 2018

how to have a running desktop accessible with x2goserver on a VPS?

  • open a terminal via ssh root 

  • ssh root@xx.xx.xx.xx 

  • adduser username

  • usermod -aG sudo username

  • vim /etc/ssh/sshd_config

  • change sshd_config as follow: 

    • Port 443

    • PermitRootLogin no

    • StrictModes yes

    • PasswordAuthentication yes

    • PermitEmptyPasswords no

    • ChallengeResponseAuthentication no

    • UsePAM yes

    • X11Forwarding yes

    • AllowUsers username@xx.xx.xx.xx lucyliu@xx.xx.xx.xx

  • /etc/init.d/ssh restart 

  • connect with new user
  • ssh username@xx.xx.xx.xx -p 443

  • install MATE

    • sudo apt update && sudo apt upgrade -y
    • sudo apt install ubuntu-mate-desktop

  • install x2goserver 
    • sudo add-apt-repository ppa:x2go/stable
    • sudo apt-get update
    • sudo apt-get install x2goserver x2goserver-xsession

how to install and keep uptodate the latest version of firefox on debian?

First install:
  • open a terminal
  • wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"
  • sudo mkdir /opt/firefox
  • sudo tar xjf FirefoxSetup.tar.bz2 -C /opt/firefox/
  • sudo mv /usr/lib/firefox-esr/firefox-esr /usr/lib/firefox-esr/firefox-esr_orig
  • sudo ln -s /opt/firefox/firefox/firefox /usr/lib/firefox-esr/firefox-esr


Getting the last update:
  • open a terminal
  • wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"
  • sudo tar xjf FirefoxSetup.tar.bz2 -C /opt/firefox/
  • restart firefox

samedi 9 juin 2018

How to deploy fresh Grails 3 app on Heroku?

Préconditions:
  • create an account on heroku.com
  • having one free dyno not already created (two dyno is the maximum for a free heroku account currently)
  • install heroku CLI
  • install sdkman/grails3

Create a new grails default app and create a file named "Profile":


$ grails create-app myapp

$ cd myapp

$ touch Procfile

"Procfile" is important for heroku plateform to configure the way the app will be launched on the plateform, copy paste this in Procfile:

web: cd build ; java -Dgrails.env=prod -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war

Then open the project inside your favorite IDE and edit build.gradle by adding this at the end of the existing file:


task stage() {
    dependsOn clean, war
}
tasks.stage.doLast() {
    delete fileTree(dir: "build/distributions")
    delete fileTree(dir: "build/assetCompile")
    delete fileTree(dir: "build/distributions")
    delete fileTree(dir: "build/libs", exclude: "*.war")
}
war.mustRunAfter clean

task copyToLib(type: Copy) {
    into "$buildDir/server"
    from(configurations.compile) {
        include "webapp-runner*"
    }
}

stage.dependsOn(copyToLib)
and also add dependency
compile 'com.github.jsimone:webapp-runner:8.5.11.3'
in the dependency section.
This dependency is for heroku to launch the app/

Then the git part:

$ git init
Initialized empty Git repository in .git/
$ git add .
$ git commit -m "first comit"
Created initial commit 5df2d09: first commit
 44 files changed, 8393 insertions(+), 0 deletions(-)
 create mode 100644 README
 create mode 100644 Procfile
 create mode 100644 app/controllers/source_file
...

Then create the heroku remote repository:

$ heroku create
$ git remote -v
heroku https://git.heroku.com/thawing-inlet-61413.git (fetch)
heroku https://git.heroku.com/thawing-inlet-61413.git (push)
$ git push heroku master

Initializing repository, done. updating 'refs/heads/master'

check the result by using

$ heroku open


Sources:
https://devcenter.heroku.com/articles/git#prerequisites-install-git-and-the-heroku-cli
https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku

bash script to convert all mp4 in a folder to mkv files with ffmpeg

 #!/bin/bash for i in *.mp4; do   echo "$i" "${i%%.*}.mkv"   ffmpeg -i "$i" -vcodec copy -acodec copy "${...