#StackBounty: #gnome #gui #gtk3 #scrolling #accessibility Turn off smooth scrolling in GTK3

Bounty: 50

On a default Ubuntu 16.04 (xenial) installation, GTK3 applications (which include most of the default GUI applications) have smooth scrolling activated. How do I disable it?

For example, in Gedit, pressing PageUp/PageDown causes the text to scroll one pixel line at a time until it settles to its final position one page further up/down. The same behavior occurs in the file selection dialog box, in Nautilus, etc. How do I turn off smooth scrolling, i.e. how do I make the PageUp/PageDown keys show the previous/next page immediately?


Get this bounty!!!

#StackBounty: #xorg #users #gui #session #xdotool Is it possible to automate clicks with xdotool to control a different GUI session fro…

Bounty: 50

The xdotool command allows us to create scripts controlling the graphical user interface of the system very easily. I can e.g. open my Chrome browser in the following desktop by executing xdotool mousemove 26 146 click 1.

enter image description here

So, let’s say that I create a new user to my system:

# adduser newuser

If I log with newuser in a different session and execute xdotool commands they work perfectly fine. But well, let’s say that I’ve opened two different GUI sessions in different ttys, one with my regular user and other with newuser, and let’s also say that I’m currently running a GUI session with my regular user and I create the following script:

#!/bin/bash

xdotool mousemove 31 61 click 1

Then I save it as macro.bash on my home folder and execute chmod 777 ~/macro.bash to set the right permissions for it. Finally, I open a new terminal and I log as newuser (while I’m currently using my regular user session):

$ su newuser

Now if I try to execute my script I get the following error (see EDIT 1):

newuser@myPC:~$ /home/myregularuser/macro.bash 
No protocol specified
Error: Can't open display: (null)
Failed creating new xdo instance

This script works fine if I try to execute it while running a GUI session logged as newuser, but my goal here is to control the graphical interface of the newuser session with scripts while I’m using my regular user session. Is it possible? Does anyone know a workaround to solve this error?


EDIT 1

As quixotic said in the comments the error was happening because my $DISPLAY variable wasn’t set for the newuser‘s shell. I managed to create a quick workaround to solve this with the following process:

1- Logging into my newuser session.

2- Inserting the following commands as the last lines of the ~/.bashrc file:

if xhost >& /dev/null; then
   echo "export DISPLAY="$DISPLAY"" > $HOME/.display
fi

3- Changing my script making it redefine the $DISPLAY variable to its right value while the script is executed:

#!/bin/bash

source $HOME/.display

xdotool mousemove 31 61 click 1

Now if I try to execute this script logged as newuser from the command line I don’t see any error.

newuser@myPC:~$ /home/myregularuser/macro.bash

But well, although the script does change the mouse location the click command isn’t working… So, the question still remains: Is it really possible to control a GUI session with scripts while I’m running a different GUI session?


EDIT 2

Following the procedure of telcoM‘s answer:

regularuser@myPC:~$ source /home/newuser/.display # Setting $DISPLAY as the newuser $DISPLAY value
regularuser@myPC:~$ su newuser -c "xauth extract /home/newuser/.Xauthority $DISPLAY" | xauth merge
xauth: (argv):1:  bad "merge" command line
Password: 
xauth:  timeout in locking authority file /run/user/1000/gdm/Xauthority

Additional information

  1. I’m running Ubuntu 18.04.
  2. The display server used is Xorg (with Wayland xdotool doesn’t work at all but this question isn’t related to Wayland).
  3. GNOME is the graphical user interface I’m currently using.


Get this bounty!!!

#StackBounty: #users #tty #gui #session #xdotool Is it possible to make the xdotool command control a GUI interface of a different tty …

Bounty: 50

The xdotool command allows us to create scripts controlling the graphical user interface of the system very easily. I can e.g. open my Chrome browser in the following desktop by executing xdotool mousemove 26 146 click 1.

enter image description here

So, let’s say that I create a new user to my system:

# adduser newuser

If I log with newuser in a different session and execute xdotool commands they work perfectly fine. But well, let’s say that I’m with two different GUI sessions in different ttys open in my system, one with my regular user and other with newuser, and let’s also say that I’m currently running a GUI session with my regular user and I create the following script:

#!/bin/bash

xdotool mousemove 31 61 click 1

Then I save it as macro.bash on my home folder and execute chmod 777 ~/macro.bash to set the right permissions for it. Finally, I open a new terminal and I log as newuser (while I’m currently using my regular user session):

$ su newuser

Now if I try to execute my script I get the following error (see EDIT 1):

newuser@myPC:~$ /home/myregularuser/macro.bash 
No protocol specified
Error: Can't open display: (null)
Failed creating new xdo instance

This script works fine if I try to execute it while running a GUI session logged as newuser, but my goal here is to control the graphical interface of the newuser session with scripts while I’m using my regular user session. Is it possible? Does anyone know a workaround to solve this error?


EDIT 1

As quixotic said in the comments the error was happening because my $DISPLAY variable wasn’t set for the newuser‘s shell. I managed to create a quick workaround to solve this with the following process:

1- Logging into my newuser session.

2- Inserting the following commands as the last lines of the ~/.bashrc file:

if xhost >& /dev/null; then
   echo "export DISPLAY="$DISPLAY"" > $HOME/.display
fi

3- Changing my script making it redefine the $DISPLAY variable to its right value while the script is executed:

#!/bin/bash

source $HOME/.display

xdotool mousemove 31 61 click 1

Now if I try to execute this script logged as newuser from the command line I don’t see any error.

newuser@myPC:~$ /home/myregularuser/macro.bash

But well, although the script does change the mouse location the click command isn’t working. I’m not sure if now it’s more an Ubuntu problem than a Linux problem… So the question still remains: Is it really possible to control a GUI session with scripts while I’m running a different GUI session?


EDIT 2

Following the procedure of telcoM‘s answer:

regularuser@myPC:~$ source /home/newuser/.display # Setting $DISPLAY as the newuser $DISPLAY value
regularuser@myPC:~$ su newuser -c "xauth extract /home/newuser/.Xauthority $DISPLAY" | xauth merge
xauth: (argv):1:  bad "merge" command line
Password: 
xauth:  timeout in locking authority file /run/user/1000/gdm/Xauthority


Get this bounty!!!

#StackBounty: #linux #gui #posix #sh Lightshot Print Screen key linux handler – Follow-up #1

Bounty: 50

This question is a direct follow-up #1 of my previous question:

Lightshot Print Screen key linux handler


There were too many errors which I didn’t see at the moment and I tried hard to fix them up now. I would like someone else (than myself) to actually review the code this time.


#!/bin/sh

# treat unset variables as an error when substituting
set -o nounset

#------------------------------------------------------------------------------

# global constants for an easy set-up
#
# lightshot_printscreen_hotkey: set this to the same hotkey which you have set up in Lightshot
#                               example: for left control and print screen key -> type Control_L+Print
lightshot_printscreen_hotkey="Print"

# lightshot_process_name: no need to change this one; it is a case-sensitive name of the Lightshot process
lightshot_process_name="Lightshot"

#------------------------------------------------------------------------------

print_error_and_exit()
# expected arguments:
# $1 = exit code
# $2 = error origin; usually function name
# $3 = error message
{
    # colors definitions
    bold=$(tput bold)
    red=$(tput setaf 1)
    yellow=$(tput setaf 3)
    nocolor=$(tput sgr0)
    bold_red="$bold$red"
    bold_yellow="$bold$yellow"

    # check if exactly 3 arguments have been passed
    # if not, print out an internal error without colors
    if [ "$#" -ne 3 ]
    then
        printf "print_error_and_exit() internal error\n\n\tThere has been passed a wrong number of arguments (%b)! Expected 3:\n\t\t1 - exit code\n\t\t2 - error origin\n\t\t3 - error message\n\nexit code = 2\n" "$#" 1>&2
        exit 2
    fi

    # check if the first argument is a number
    # if not, print out an internal error without colors
    if ! [ "$1" -eq "$1" ] 2> /dev/null
    then
        printf "print_error_and_exit() internal error\n\n\tThere has been passed the first argument as not a number (%b)!\n\tExpected an exit code.\n\nexit code = 2\n" "$1" 1>&2
        exit 2
    fi

    # check if we have color support
    if [ -x /usr/bin/tput ] && tput setaf 1 > /dev/null 2>&1
    then
        # here we do have color support, so we highlight the error origin and the exit code
        printf "%b%b()\n\n\t%b%b%b\n\nexit code = %b%b\n" "$bold_yellow" "$2" "$nocolor" "$3" "$bold_red" "$1" "$nocolor" 1>&2
        exit "$1"
    else
        printf "%b()\n\n\t%b\n\nexit code = %b\n" "$2" "$3" "$1" 1>&2
        exit "$1"
    fi
}

#------------------------------------------------------------------------------

# expected arguments to the script: none
# check if no arguments have been passed to the script
[ "$#" -gt 0 ] && print_error_and_exit 1 "$0" "You have passed $# unexpected argument(s) to the script!\n\tNo arguments expected."

#------------------------------------------------------------------------------

check_for_prerequisite()
# expected arguments:
# $1 = program name
{
    # check if exactly one argument has been passed
    [ "$#" -eq 1 ] || print_error_and_exit 3 "check_for_prerequisite" "There has not been passed exactly one argument!\n\tA program name expected."

    # check if the argument is a program which is installed
    command -v "$1" > /dev/null 2>&1 || print_error_and_exit 4 "check_for_prerequisite" "I require $1 but it is not installed! Please install it."
}

#------------------------------------------------------------------------------

# check for prerequisites
check_for_prerequisite "pgrep"
check_for_prerequisite "xdotool"

#------------------------------------------------------------------------------

get_process_id_using_process_name()
# expected arguments:
# $1 = process name
{
    # check if exactly one argument has been passed
    [ "$#" -eq 1 ] || print_error_and_exit 5 "get_process_id_using_process_name" "There has not been passed exactly one argument!\n\tA process name expected."

    # try to get the process id using the process name
    pgrep "$1"
}

#------------------------------------------------------------------------------

is_number()
# expected arguments:
# $1 = any variable
{
    # check if exactly one argument has been passed
    [ "$#" -eq 1 ] || print_error_and_exit 6 "is_number" "There has not been passed exactly one argument!\n\tOne variable to test expected."

    # check if the argument is an integer number 
    [ "$1" -eq "$1" ] 2> /dev/null
}

#------------------------------------------------------------------------------

# try to get the Lightshot process id
lightshot_process_id=$(get_process_id_using_process_name "$lightshot_process_name")

# test if a process id has been successfully acquired
is_number "$lightshot_process_id" || print_error_and_exit 7 "lightshot_process_id" "The argument is not a number!\n\tLightshot is most probably not running."

#------------------------------------------------------------------------------

# get the window id from the Lightshot process id
    #--all   : Require that all conditions be met.
    #--limit : Stop searching after finding N matching windows.
    #--pid   : Match windows that belong to a specific process id.
    #--name  : Match against the window name. This is the same string that is displayed in the window titlebar.
lightshot_window_id=$(xdotool search --all --limit 1 --pid "$lightshot_process_id" --name "$lightshot_process_name")

# test if a window id has been successfully acquired
is_number "$lightshot_window_id" || print_error_and_exit 8 "lightshot_window_id" "The argument is not a number!\n\tLightshot is most probably not running."

#------------------------------------------------------------------------------

# simulate the above pre-defined print screen hotkey press on the Lightshot window
xdotool key --window "$lightshot_window_id" "$lightshot_printscreen_hotkey"


Get this bounty!!!

#StackBounty: #permissions #password #startup #gui #gksudo Every application which require admin password won't open

Bounty: 50

Something happened few days ago in my Xubuntu 14.04. None of applications which require admin password won’t open. Apps like GParted, Update Manager, File Manager when trying to open a folder as root, etc…

No matter how I start them. From the menu, desktop or in terminal using gksudo. In every case after entering the (the correct) password, the password dialog hides away and then the indicator light of the hard disk starts to blink heavily. But app window won’t show up. Task Manager shows that the app uses 25% of CPU-time. And this keeps going no matter how long I wait.

Updating and upgrading work fine when started in terminal using sudo. Nano, leafpad and any GUI apps work fine even when started in terminal as NORMAL user, but not with gksudo nor sudo…

My username has sudo & adm groups. All been working fine for years but suddenly this problem occured. I’m wondering that hard disk usage which never ends. To get rid of that the OS must be rebooted.

So guys, how to sort this out?


Get this bounty!!!

#StackBounty: #permissions #password #startup #gui #gksudo Every application which require admin password won't open

Bounty: 50

Something happened few days ago in my Xubuntu 14.04. None of applications which require admin password won’t open. Apps like GParted, Update Manager, File Manager when trying to open a folder as root, etc…

No matter how I start them. From the menu, desktop or in terminal using gksudo. In every case after entering the (the correct) password, the password dialog hides away and then the indicator light of the hard disk starts to blink heavily. But app window won’t show up. Task Manager shows that the app uses 25% of CPU-time. And this keeps going no matter how long I wait.

Updating and upgrading work fine when started in terminal using sudo. Nano, leafpad and any GUI apps work fine even when started in terminal as NORMAL user, but not with gksudo nor sudo…

My username has sudo & adm groups. All been working fine for years but suddenly this problem occured. I’m wondering that hard disk usage which never ends. To get rid of that the OS must be rebooted.

So guys, how to sort this out?


Get this bounty!!!

#StackBounty: #permissions #password #startup #gui #gksudo Every application which require admin password won't open

Bounty: 50

Something happened few days ago in my Xubuntu 14.04. None of applications which require admin password won’t open. Apps like GParted, Update Manager, File Manager when trying to open a folder as root, etc…

No matter how I start them. From the menu, desktop or in terminal using gksudo. In every case after entering the (the correct) password, the password dialog hides away and then the indicator light of the hard disk starts to blink heavily. But app window won’t show up. Task Manager shows that the app uses 25% of CPU-time. And this keeps going no matter how long I wait.

Updating and upgrading work fine when started in terminal using sudo. Nano, leafpad and any GUI apps work fine even when started in terminal as NORMAL user, but not with gksudo nor sudo…

My username has sudo & adm groups. All been working fine for years but suddenly this problem occured. I’m wondering that hard disk usage which never ends. To get rid of that the OS must be rebooted.

So guys, how to sort this out?


Get this bounty!!!

#StackBounty: #permissions #password #startup #gui #gksudo Every application which require admin password won't open

Bounty: 50

Something happened few days ago in my Xubuntu 14.04. None of applications which require admin password won’t open. Apps like GParted, Update Manager, File Manager when trying to open a folder as root, etc…

No matter how I start them. From the menu, desktop or in terminal using gksudo. In every case after entering the (the correct) password, the password dialog hides away and then the indicator light of the hard disk starts to blink heavily. But app window won’t show up. Task Manager shows that the app uses 25% of CPU-time. And this keeps going no matter how long I wait.

Updating and upgrading work fine when started in terminal using sudo. Nano, leafpad and any GUI apps work fine even when started in terminal as NORMAL user, but not with gksudo nor sudo…

My username has sudo & adm groups. All been working fine for years but suddenly this problem occured. I’m wondering that hard disk usage which never ends. To get rid of that the OS must be rebooted.

So guys, how to sort this out?


Get this bounty!!!

#StackBounty: #permissions #password #startup #gui #gksudo Every application which require admin password won't open

Bounty: 50

Something happened few days ago in my Xubuntu 14.04. None of applications which require admin password won’t open. Apps like GParted, Update Manager, File Manager when trying to open a folder as root, etc…

No matter how I start them. From the menu, desktop or in terminal using gksudo. In every case after entering the (the correct) password, the password dialog hides away and then the indicator light of the hard disk starts to blink heavily. But app window won’t show up. Task Manager shows that the app uses 25% of CPU-time. And this keeps going no matter how long I wait.

Updating and upgrading work fine when started in terminal using sudo. Nano, leafpad and any GUI apps work fine even when started in terminal as NORMAL user, but not with gksudo nor sudo…

My username has sudo & adm groups. All been working fine for years but suddenly this problem occured. I’m wondering that hard disk usage which never ends. To get rid of that the OS must be rebooted.

So guys, how to sort this out?


Get this bounty!!!

#StackBounty: #permissions #password #startup #gui #gksudo Every application which require admin password won't open

Bounty: 50

Something happened few days ago in my Xubuntu 14.04. None of applications which require admin password won’t open. Apps like GParted, Update Manager, File Manager when trying to open a folder as root, etc…

No matter how I start them. From the menu, desktop or in terminal using gksudo. In every case after entering the (the correct) password, the password dialog hides away and then the indicator light of the hard disk starts to blink heavily. But app window won’t show up. Task Manager shows that the app uses 25% of CPU-time. And this keeps going no matter how long I wait.

Updating and upgrading work fine when started in terminal using sudo. Nano, leafpad and any GUI apps work fine even when started in terminal as NORMAL user, but not with gksudo nor sudo…

My username has sudo & adm groups. All been working fine for years but suddenly this problem occured. I’m wondering that hard disk usage which never ends. To get rid of that the OS must be rebooted.

So guys, how to sort this out?


Get this bounty!!!