A következő címkéjű bejegyzések mutatása: workaround. Összes bejegyzés megjelenítése
A következő címkéjű bejegyzések mutatása: workaround. Összes bejegyzés megjelenítése

2019. augusztus 3.

Display settings lost on reboot

As described here, this problem is affecting others as well:
Here are the steps I tool to assemble the little script below:

How many displays do you have right now?
xrandr | grep -w connected | wc -l
How to position your displays?
xrandr --output PRIMARY-SCREEN-ID --below SECONDARY-SCREEN-ID
How to rotate a display?
xrandr --output SCREEN-ID --rotate [normal|left|right|inverted]
How to get your display IDs?
primary display:
xrandr | grep -w connected | grep primary | cut -d' ' -f1
secondary display:
xrandr | grep -w connected | grep -v primary | cut -d' ' -f1
How to position your gnome-panels?
Apparently there is no easy way, but for the note, here's where to find these setting:
org.gnome.gnome-panel.layout.toplevels.bottom-panel monitor 0
org.gnome.gnome-panel.layout.toplevels.top-panel monitor 1

Here's the script I put into my .bashrc (.profile would be also a good place for it) to restore the positions of my displays (I have the laptop below the monitor).

# set dual display positions
# because they are forgotten after logout
function reset_displays {
 display_count=`xrandr | grep -w connected | wc -l`
 if [ "$display_count" -eq "2" ]; then
  id1=`xrandr | grep -w connected | grep primary | cut -d' ' -f1`
  id2=`xrandr | grep -w connected | grep -v primary | cut -d' ' -f1`
  xrandr --output $id2 --rotate normal
  xrandr --output $id1 --below $id2
 fi
}
reset_displays

2015. január 25.

Nautilus scripting in bash: processing multiple files / handle space in filenames

Where do I put the scripts? 

Nautilus scripts folder is in your user home directory:
in Ubuntu 12.04 and before: .gnome2/nautilus-scripts/
from Ubuntu 14.04: .local/share/nautilus/scripts/

You'll have to make all script files executable in order to be able to run them.
chmod +x

What does a nautilus script do? 

All executable files in this folder will appear in the Scripts menu. Choosing a script from the menu will run that script.

When executed from a local folder, scripts will be passed the selected file names. When executed from a remote folder (e.g. a folder showing web or ftp content), scripts will be passed no parameters.

What nautilus script specific variables can I use?

In all cases, the following environment variables will be set by Nautilus, which the scripts may use:

  • NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
    # newline-delimited paths for selected files (only if local)
  • NAUTILUS_SCRIPT_SELECTED_URIS
    # newline-delimited URIs for selected files
  • NAUTILUS_SCRIPT_CURRENT_URI
    # URI for current location
  • NAUTILUS_SCRIPT_WINDOW_GEOMETRY
    # position and size of current window
# from Ubuntu 14.04 Nautilus does not have split view (extra pane), so these variables (most likely) will not work:
  • NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_FILE_PATHS
    # newline-delimited paths for selected files in the inactive pane of a split-view window (only if local)
  • NAUTILUS_SCRIPT_NEXT_PANE_SELECTED_URIS
    # newline-delimited URIs for selected files in the inactive pane of a split-view window
  • NAUTILUS_SCRIPT_NEXT_PANE_CURRENT_URI
    # URI for current location in the inactive pane of a split-view window
How do these variables work? 

To test what these variables do you might use this nautilus script:
#!/bin/bash
# test your nautilus variables
touch $HOME/nautilustesting.txt
echo "SELECTED_FILE_PATHS: " "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" >> $HOME/nautilustesting.txt
echo "SELECTED_URIS: " "$NAUTILUS_SCRIPT_SELECTED_URIS"  >> $HOME/nautilustesting.txt
echo "CURRENT_URI: " "$NAUTILUS_SCRIPT_CURRENT_URI" >> $HOME/nautilustesting.txt
echo "WINDOW_GEOMETRY: " "$NAUTILUS_SCRIPT_WINDOW_GEOMETRY" >> $HOME/nautilustesting.txt
echo " " >> $HOME/nautilustesting.txt

How to use these variables?

The variables you get will look something like this (in case of selecting 4 files with spaces in the names):
SELECTED_FILE_PATHS:  /home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen inverted
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen left
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen normal
/home/username/.gnome2/nautilus-scripts/Screen rotate/Set screen right (notes)
SELECTED_URIS:  file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20inverted
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20left
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20normal
file:///home/username/.gnome2/nautilus-scripts/Screen%20rotate/Set%20screen%20right%20(notes)
CURRENT_URI:  file:///home/username/.gnome2/nautilus-scripts
WINDOW_GEOMETRY:  1022x690+0+1024

How to read nautilus selected file paths with spaces into a bash array?

To have a use of them as input file path for example imagemagick, I'll have to deal with the spaces, because these command line programs usually take "file path" as input and do not take "file URI" as input, and file path may contain spaces.

The FAQ of the G-Scripts site suggests some ways to handle this:
  1. protect your variable with double quotes: instead of $1 use "$1"
  2. process the filenames with SED:
    files=`echo "$1" | sed 's/ /\\ /g'`
  3. process the filenames with AWK and SED:
    quoted=$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN {FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##); eval "your-program $quoted"
Actually, for me NONE of the above worked.
I found my solution in a stackoverflow post. It uses the IFS value to deal with the filenames. I read somewhere that using the IFS is an inelegant way to deal with field separators, and one should use AWK FS variable instead.

My solution: 

This is to use with nautilus scripts:
IFS=$'\n' read -d '' -r -a filelist < <(printf '%s\n' "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"); unset $IFS
This is to use with my image manipulation scripts (where the script file is located in the same folder as the to-b-manipulated files):
IFS=$'\n' read -d "" -r -a filelist < <(find -iname "*.jpg" | sort); unset $IFS
When you want to call the elements of the array, you'll have to put them in double quotes, like
for i in "${filelist[@]}" 
do echo "$i"
done
Google search keywords to find the solution:

  • escape space in bash script
  • awk fs line break
  • sed change space to newline
  • escape space in bash script with sed
  • internal field separator
  • bash read file names into array
  • bash read space file names into array
  • echo into array bash
  • while read output array bash


2015. január 22.

A selection of Lightweight Ubuntu alternatives

I was considering to leave Ubuntu, and therefor I searched for alternatives.
These are the ones I found worthy of trying out in the first round:


CrunchBang Linux Lubuntu wattOS LXLE Bodhi Linux
OS Type: Linux Linux Linux Linux Linux
Based on: Debian (Stable) Debian, Ubuntu Debian, Ubuntu Debian, Lubuntu Debian, Ubuntu
Origin: United Kingdom France, Taiwan USA USA USA
Architecture: i486, i686, x86_64 armhf, i386, powerpc, x86_64 i386, x86_64 i386, x86_64 armhf, i386, x86_64
Desktop Manager: Openbox LXDE, Openbox LXDE, MATE, Openbox LXDE Enlightenment
Windows Manager: Openbox? Openbox Openbox Openbox? Enlightenment
File Manager: Thunar File Manager PCManFM PCManFM PCManFM EFM
Category: Desktop, Netbooks, Old Computers Live Medium, Netbooks, Old Computers Desktop, Live Medium, Netbooks, Old Computers Desktop, Live Medium, Old Computers Desktop, Live Medium, Old Computers, Raspberry Pi
Status: Active Active Active Active Active
Popularity: 22 (478 hits per day) 15 (723 hits per day) 58 (249 hits per day) 11 (770 hits per day) 20 (548 hits per day)
Official page: http://crunchbang.org/ http://lubuntu.net/ http://www.planetwatt.com/ http://lxle.net

What I need from my OS, is written in a previous post. I'll use this as a checklist when trying out the new distributions.

2015. január 18.

Gnome Classic tweaks on Ubuntu 12.04.5 Precise Pangolin compared to 14.04.1 Trusty Thar

In this post I'm going to configure Ubuntu 12.04.5. LTS to my taste. Since I configured a 14.04.1 LTS just a couple of weeks ago the exact same way, I will compare the how-to of these settings.

What do I need from Ubuntu?
- this post has the list of features I'm going to test against Precise Pangolin.

Desktop Environment Choices
- I chose Gnome Flashback Services again, but in 12.04 it is called Gnome Classic (with or without effects) and can be installed by installing the package gnome-session-fallback instead of gnome-session-flashback.
- Synaptic package manager is not installed by default on 12.04, just like on 14.04, so it has to be installed from terminal with the sudo apt-get install synaptic command (or probably from Ubuntu Software Center, which I prefer to not use)

All the following notes are based on using Gnome Classic without Effects.

Setting up everything

Gnome Classic is somewhat different from Gnome Session Flashback.
Some useful tips can be found in this ubuntu forum thread.

Otherwise, compared to Ubuntu 14.04:
  • HP Compaq TC4400 native features:
    • pen features: the same
    • screen rotation: the same
    • on-screen buttons: the same
  • Terminal: the same
  • Workspaces: the same
  • Panels: the same
  • Synaptic: the same
  • File manager: Nautilus still can do all I want, so I'll stick with it.
    • Scripts: the same
    • Open in Terminal: the same (install nautilus-open-terminal package to get right click option "Open Terminal") 
Tablet input usage in multi-screen environment compared to Ubuntu 10.04 Lucid Lynx:
  • xinput has a new version, and it enables to map the tablet input device to the tablet screen by using xinput --map-to-crtc device crtc
    • where device is the device ID of the stylus or the eraser taken from xinput --list
    • and the crtc is the name of the tablet monitor taken from xrandr
    Changing the Date and Time format in the indicator applet
    - on Precise there is no configuration editor pre-installed.
    - DConf Editor can be installed by installing dconf-tools - then it will be available as dconf-editor of from the Applications menu > System Tools > DConf Editor
    - after installing it, setting custom date and time format can be done as in Trusty, described in the post linked above.

    Indicator Applet
    - Gnome Classic installs indicator-applet-complete, but there are more then one indicator applet that can be downloaded with synaptic. The difference between them is this:
    • indicator-applet-complete is: messaging applications, power settings, bluetooth settings, network settings, sound settings, date and time settings, user accounts, session management
    • indicator-applet is: messaging applications, power settings, bluetooth settings, network settings, sound settings
    • indicator-applet-session is: user accounts, session management
    • indicator-applet-appmenu is: your active application's menu header
    Some modifications can be made to the features shown in the indicator applet with DConf editor - as described above. 

    Remove messaging envelope from indicator applet
    This AskUbuntu post holds the solution: to remove just the envelope icon from the indicator applet indicator-messages package has to be removed with sudo apt-get remove indicator-messages and then gnome-panel restarted with sudo pkill gnome-panel

    Running Java Applets on websites
    - icedtea-7-plugin solves this on Ubuntu 12.04.5, just like it does on 14.04.1.

    Reserving space for the top panel between monitors
    the same, except for the panel height. It is still 24 pixels, but when set with _NET_WM_STRUT_PARTIAL 1024,0,0,0,1024,1048,0,0,0,0,0,0 a single pixel space remains under it, so it has to be set with _NET_WM_STRUT_PARTIAL 1024,0,0,0,1024,1047,0,0,0,0,0,0

    Enable Compositing for Gnome Classic without effects
    In Trusty Thar Metacity Compositing can be enabled by opening dconf-editor and navigating to > org > gnome > metacity > compositing-manager > mark checked.
    In Precise Pangolin there is no such option in dconf-editor. Instead you'll have to install gconf-editor and set it there. Once installed, you can find it in the Applications menu > System Tools > Configuration Editor. Inside it navigate to apps > metacity > general and set a checkmark next to "compositing_manager"
    This will enable real window transparency (i.e. terminal window), window shadow, Alt+Tab window selector shows screenshot of the window; and it is said to support AWN, and Gnome Do, but I did not try these.

    Aero Snap for Gnome Classic (no effects)
    the same, except for the key combinations: in Ubuntu 12.04 instead of Mod4 + Super_L + Left combination it is only Mod4 + Left

    Repository download checklist:
    • synaptic
    • gnome-session-fallback
    • nautilus-open-terminal
    • wmctrl
    • xbindkeys
    • dconf-tools
    • gconf-editor
    • gimp (GUI image manipulation tool)
    • inkscape (GUI vector-based drawing program)
    • imagemagick (convert, mogrify, identify)
    • pdftk
    • pdfjam (pdfjoin)
    • djvulibre-bin (ddjvu, djvused, cjb2, djvm, c44)
    • potrace (mkbitmap)
    • unpaper
    • keepass2
    • keepassX
    • nautilus-dropbox (Dropbox) fails to complete installation.
    Web download checklist:
    to install deb packages run sudo dpkg --install [packagename.deb]
    to install packages with dependencies, install gdebi first from synaptic, then run sudo gdebi [packagename.deb] - gdebi is like Ubuntu Software Center ("USC") in the Command Line Interface ("CLI")
    • Dropbox: does not show system tray indicator in notification area (see description below)
    • Skype: looks all right.
    • Rescuetime: looks all right.
    • Plex Media Server: looks all right.
    • Google Chrome: looks all right.
    Dropbox installation troubles:
    - when installing nautilus-dropbox the process failed to move forward after downloading 100% of the dropbox installer. After killing this process somehow, I could not install anything, but got the message: "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem." So I did as was asked, and then nautilus-dropbox configuration continued with downloading the installer and stopping after 100% again. I could get out of this infinite loop by following the instructions in this post. I edited the /var/lib/dpkg/info/nautilus-dropbox.postinst file and inserted a "exit 0" line as the second line right after the "#!" line. Then dpkg could finish the process by quitting without really configuring dropbox, so after this I removed the whole thing with sudo apt-get remove nautilus-dropbox and intalled the deb package downloaded from dropbox site.
    - the deb package installed all right, but the dropbox tray icon is missing from the notification area. I searched for a solution, and some places suggest removing dropbox and installing nautilus-dropbox instead, but this obviously will not work for me. Another post is suggesting more ways to get the icon working, and I tried all of it (notification area, unity-panel whitelist, autostart y), but none of them worked.
    - I added the dropbox gpg key to the repositiry, did an apt-get update, and than tried to install nautilus-dropbox, but got the message: "Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies:  nautilus-dropbox : Depends: dropbox but it is not going to be installed E: Unable to correct problems, you have held broken packages." So I searched, and found, and did an apt-get upgrade, which upgraded dropbox only, because this was the broken package, and then after restarting dropbox, nautilus and gnome-panel, there was this 1x1 pixel white dot in the notification area, which on mouse-over shows a label "Dropbox 3.0.5 Up to date" and can be right-clicked to reach dropbox menu. Nautilus-dropbox is still not installed as a package.
    - when I copied the dropbox icons to the icon fallback directory, the dropbox icon showed up on the panel.
    Dropbox icons are stored in the /home/[user]/.dropbox-dist/dropbox-[version]/images/hicolor/16x16/status/
    Icon fallback directory for them is /usr/share/icons/hicolor/16x16/status/
    However, after restarting the panel it was only the 1x1 pixel dot again, and restarting dropbox didn't help. Icons are still there in the fallback directory.
    A note: Skype puts it's icon next to the Dropbox pixel, and it works perfectly, so the problem is definitely with Dropbox.

    2015. január 11.

    Aero Snap for extended display on different screen resolutions - a workaround

    In this AskUbuntu post, a solution is described to have the Aero snap to left and right in Metacity Ubuntu. I covered the content of the post previously based on the post, and added a snap up and snap down function too.

    This AskUbuntu post, from the same user, is aiming to develop the solution further for multiple monitors. Based on this post I'll do my own workaround.

    I have two displays. One is 1024x768, the other is 1280x1024 in resolution.
    I either put them beside or on top of each other.
    I already worked out the usage of the tablet screen as a tablet in similar settings.

    I will call displays beside each other "Sided", and displays on top of each other "Topped".

    Sided screen is 2304x1024, Topped is 1280x1792 in resolution.

    The script as is, puts the active window according to this table:
    SnapSided displayTopped display
    leftleft screenbigger screen left
    rightright screenbigger screen right
    upbigger screen upupper screen
    downbigger screen downlower screen

    There are problems with the resized window's sizes, caused by the different screen sizes and the expanded edge panels (top and bottom panel). This is what I would like to fix.

    Defining screens
    the tool for dynamic screen manipulation is xrandr.

    Normal/Default (with only one screen and the expanded edge panels (top+bottom) in place)
    Small display maximized window is 1024x692 in position 0:80
    Big display maximized window is 1280x948 in position 0:80


    Topped Displays
    Small display (with panels) maximized window is 1024x716 in position 0:1080
    Small display maximized window is 1024x740 in position 0:1080
    Big display (with panels) maximized window is 1280x972 in position 0:80
    Big display maximized window is 1280x996 in position 0:56

    As is visible from the altering numbers, either the top or the bottom of the windows are hidden under the edge panels in the Topped view.
    This is a problem experienced by different users in AskUbuntu and elsewhere.
    It is caused because "panels in between monitors are not supported, and this is a limitation in the freedesktop specification for reserving space for things like panels."

    # What is my Desktop Manager? ("dm")
    ~$ env | grep XDG_CURRENT_DESKTOP
    Mine is GNOME.

    # What is my Window Manager? ("wm")
    ~$ wmctrl -m
    Mine is Metacity. It's configuration tool is gconftool-2.
    It can be set to be a compositing window manager (like compiz but simpler) by opening dconf-editor and navigating to > org > gnome > metacity > compositing-manager > mark checked. It has these features: real window transparency (i.e. terminal window), window shadow, Alt+Tab window selector shows screenshot of the window; it is said to support AWN, and Gnome Do.


    #What is EWMH?
    EWMH is a standard for window management. For more info visit this site.

    # What is the full size of the display?
    that is given by ~$ wmctrl -G -l | grep Desktop
    or by ~$ xwininfo -root | grep Height and ~$ xwininfo -root | grep Width
    or by ~$ xwininfo -root | egrep '(Height|Depth)' displayed in two rows.

    # Is the view topped or sided?
    if width>height it is the sided view, else it is the topped view.

    # What are the single display sizes?
    they are given by xrandr -q | grep '*' displayed in two rows.

    #What are the names of the displays?
    they are given in ~$ xrandr -q
    my displays are LVDS1 and VGA1 indicating the connection port they use.

    # How many displays do I have?
    ~$ xrandr -q | grep -c -w connected

    # What are the positions (coordinates) of the displays?
    they are given in ~$ xrandr -q in the form of XxY+W+H where the W and H are the x and y positions

    # Which display has the edge panels?
    the primary display has them. that is given by ~$ xrandr -q | grep -w primary

    #What do I need?
    • I need the edge panes handled so they would not hide any portion of the maximized windows. --> partially done.
    • I need new scripts for moving a windows to either one of the displays.
    • I need the snap-to-sides scripts to work within the screen where the window actually is.
    • A next step would be if this whole thing would work by dragging the windows to the side of the screen, like on Microsoft Windows.
    #References
    #Tools (manpages)

    2011. március 11.

    Sorting out input devices 4.

    As I wrote in the previous post, the pen tip cursor started jumping.
    This time I did not only separate the Eraser into a new cursor, but I did it with the Pen too, so now there are 3 cursors on my desktop, and I'm waiting for one of them to jump.

    2010. június 1.

    Sorting out input devices 2.

    I didn't experience the cursor jumping jet today.
    What I did today was

    ~$ sudo gedit /usr/lib/X11/xorg.conf.d/10-wacom.conf

    now it looks like:

    Section "InputClass"
    Identifier "Wacom serial class"
    MatchProduct "Serial Wacom Tablet"
    MatchDevicePath "/dev/ttyS0"
    Driver "wacom"
    # Option "Device""/dev/ttyS0"
    # Option "Type" "stylus"
    Option "ForceDevice" "ISDV4"
    Option "Button2" "3"
    # Option "Button3" "4"
    Option "TPCButton" "on"
    EndSection

    Section "InputClass"
    Identifier "Wacom serial class"
    MatchProduct "Serial Wacom Tablet eraser"
    MatchDevicePath "/dev/ttyS0"
    Driver "wacom"
    # Option "Device""/dev/ttyS0"
    # Option "Type" "eraser"
    Option "ForceDevice" "ISDV4"
    Option "TPCButton" "on"
    EndSection


    And works just right. We'll see what's gonna happen with the jumping.
    What I basically did here was to add eraser and add proper device path, and remove unnecessary entries, like the one for supporting touch, and another one, which I don't know what it was for.

    I didn't try removing the #-s jet. I jus put them in in case I want to adjust the file further to match what xorg.conf used to be before Lucid.

    2010. május 31.

    Sorting out input devices

    The general problem is:
    The cursor jumps around and clicks on things. As described here.
    This post is dedicated to cornering and trying to solve the problem.
    EDIT: as it turned out it was a hardware problem.