Have troubles with bash script: xubuntu systemd.link onboard


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Have troubles with bash script: xubuntu systemd.link onboard
# 1  
Old 03-01-2017
Have troubles with bash script: xubuntu systemd.link onboard

Hey there.
I'm new in write bash scripts in fact this is my first one so please be patient Smilie. Also english is not my native language but i hope you understand me anyway.

I installed xubuntu on my mothers laptop and every time a new version update gets installed the keyboard doesn't work anymore

i had to reconfigure it by
Quote:
sudo dpkg-reconfigure keyboard-configuration
So to get her the possibility to solve this problem by her self i wrote a small bash script to enable onboard keyboard (to input sudo password & menu navigation) and run this specific command.

Code:
#!/bin/bash
onboard
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration"
killall onboard

The problem i got is that the terminal isn't open all the time. Most time i have to run the script twice then the terminal shows up. I guess i've done a really simple mistake which i just can't see yet.

How can i solve this or is there maybe a more simple way to solve it?

Greetings & Thanks for your help
Apop

---------- Post updated 1st Mar 2017 at 08:49 AM ---------- Previous update was 28th Feb 2017 at 06:11 PM ----------

Tried out some things now like run the onboard command in a seperate instance with
"onboard $" but didn't help.

I also tried
Code:
onboard; xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration"

It just feels like the bash "script" gots stuck after executing a command.

The way i want it to work is
  1. Open onboard keyboard
  2. Open terminal and execute keyboard reconfiguration / or alternative solution for the "keyboard not working after update"-problem
  3. After the reconfiguration close keyboard
  4. EOF

The best result i got so far is
Code:
#!/bin/bash
set -e
onboard
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration"
killall onboard
killall reconfig
exit 0

Almost working but still i need to run it at least twice to get both commands be executed.

Last edited by Apop85; 03-01-2017 at 02:09 PM..
# 2  
Old 03-01-2017
Quote:
Originally Posted by Apop85
The problem i got is that the terminal isn't open all the time. Most time i have to run the script twice then the terminal shows up.

..

Tried out some things now like run the onboard command in a seperate instance with
"onboard $" but didn't help.
Can I suggest running the onboard command in the background with & like this:

Code:
#!/bin/bash
onboard &
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration"
killall onboard
killall reconfig
exit 0

This User Gave Thanks to Chubler_XL For This Post:
# 3  
Old 03-01-2017
Quote:
Originally Posted by Chubler_XL
Can I suggest running the onboard command in the background with & like this:

Code:
#!/bin/bash
onboard &
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration"
killall onboard
killall reconfig
exit 0

Have tried this but if i run onboard in the background the keyboard don't shows up. Only the terminal opens in this case.

I also tried the while command just for try&error but don't figured out yet how to exit the loop without repeating it.
Code:
#!/bin/bash
while onboard
do xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration"
done
killall onboard
killall reconfig
exit 0

Edit:

if i run the onboard command in the terminal i get following message and the window gets blocked (no other commands possible):
Quote:
WARNING Config: mousetweaks GSettings schema not found, mousetweaks integration disabled.
might this cause this problem?

---------- Post updated at 07:52 PM ---------- Previous update was at 06:42 PM ----------

Ok solved the "onboard problem" with using exec. Now both commands runs all the time but now the keyboard isn't closing after the reconfiguration is done.

Code:
#!/bin/bash
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration" &
exec onboard
killall onboard
killall testrun
exit 0

How can i loop a if command like this at the end?
Code:
if ! pgrep -x "xfce4-terminal" > /dev/null
then
       killall onboard
fi

As the terminal get closed by itself after the reconfiguration i thought about to check if the terminal still is open and if not close keyboard.

Sorry for all those noob questions Smilie

Last edited by Apop85; 03-01-2017 at 10:13 PM..
# 4  
Old 03-01-2017
Quote:
Originally Posted by Apop85
Ok solved the "onboard problem" with using exec. Now both commands runs all the time but now the keyboard isn't closing after the reconfiguration is done.

...
As the terminal get closed by itself after the reconfiguration i thought about to check if the terminal still is open and if not close keyboard.
Try running terminal in the background and then waiting for it before killing the popup like this:

Code:
#!/bin/bash
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration" &
onboard
wait
killall onboard
killall testrun
exit 0

# 5  
Old 03-01-2017
Hm nope onboard is still running with this solution
# 6  
Old 03-02-2017
We could try looping with:

Code:
#!/bin/bash
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration" &
onboard
while pgrep -x "xfce4-terminal" > /dev/null
do
    sleep 0.5
done
killall onboard

or prehaps this:

Code:
#!/bin/bash
xfce4-terminal -e "sudo dpkg-reconfigure keyboard-configuration" &
onboard
while pgrep -x "dpkg-reconfigure" > /dev/null
do
    sleep 0.5
done
killall onboard

# 7  
Old 03-02-2017
I will try it. I also checked the output of bash -x and i saw that the script seems to stop after executing onboard. I had some echoes at the end but they didn't get printed.

Code:
bash -x testrun
+ exec onboard
+ xfce4-terminal -e 'sudo dpkg-reconfigure keyboard-configuration'
21:02:47.517 WARNING Config: mousetweaks GSettings schema not found, mousetweaks integration disabled.

---------- Post updated at 03:11 PM ---------- Previous update was at 03:07 PM ----------

Nope same problem with the loop. Script get stopped after executing onboard command

EDIT:
I wrote also in the ubuntuforums for help with the onboard command as it is related to ubuntu in the software center i hoped they may can help me out with this Smilie But forum seems to be inactive since january 17

Troubles with starting onboard keyboard with bash script

Last edited by Apop85; 03-02-2017 at 05:04 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Systemd cant start my script

Hi, systemd cant start my script, but it work, at command prompt. Code and execute at command prompt #cat collector.sh #!/bin/bash case $1 in start) /home/postgres/scripts/pgwatch2/pgwatch2.sh /home/postgres/scripts/pgwatch2/pgwatch2_UI.sh ;; ... (7 Replies)
Discussion started by: kvaikla
7 Replies

2. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

3. UNIX for Beginners Questions & Answers

Troubles running DB2 command in shell script via cron

Hi there, Now I'm facing error regarding running shell script via cron. The shell script which is required to get value from database. Below is the main part of shell script. #/bin/bash #connect to database(1) db2 connect to $database user xxxx using yyyy #set values from... (3 Replies)
Discussion started by: Rohan Kishibe
3 Replies

4. Hardware

Seeking advice on onboard graphic card

Hi all, I'm prepared building a new PC for testing ONLY. I don't game. Neither I'll do graphic editing on the new box. There are about 30 VMs installed running VirtualBox as virtualizer but not all of them running at the same time. Most VMs are servers. I do configuration on terminal with... (4 Replies)
Discussion started by: satimis
4 Replies

5. Red Hat

Enter Bios and disable onboard NICS?

Hi, I have to get into BIOS and disable onbaord NICS for an IBM server, can someone please help me out. I tried hitting F1 when reboot to get into BIOS, but it seems like a setup screen and I dont see any option to disable NICS? Thanks Sam (0 Replies)
Discussion started by: sam4919
0 Replies

6. Shell Programming and Scripting

Troubles with shell script

Hello. I'm having trouble figuring out how to write this script. I'm supposed to have my script start up with specific arguments and if there are missing arguments or invalid arguments, return an error associated to its errorlevel number. For example, here are a few errorlevel numbers with their... (4 Replies)
Discussion started by: Simonpalmieri
4 Replies

7. Solaris

Ultra 10 Creator 3D: enabling onboard VGA

Hello, I have an Ultra 10 Creator 3D working fine with a Sun monitor, but I'd like to use it with a VGA flat panel (it would be great if I could use both screens simultaneously). As I've read in a previous thread (https://www.unix.com/sun-solaris/14875-creator-3d-video-adapter.html) this box... (1 Reply)
Discussion started by: ama
1 Replies

8. Shell Programming and Scripting

[BASH] Remove Link from Filename

Hi there, I'm trying to make a script that downloads something, but then strips the URL for later processing. A user would input the following: ./text -install <link> Lets say the <link> is: Later on, the script would have to; unpack the file with the command: tar xvf... (6 Replies)
Discussion started by: Syekiya
6 Replies

9. AIX

Onboard Sound

Is there a command to make the onboard sound beep? (0 Replies)
Discussion started by: dig1tal
0 Replies

10. UNIX for Advanced & Expert Users

Identifying onboard PCI device

Hi all, I have customized tool that displays PCI device information (something similar to the linux - "lspci") . Now, I need to display information only on "plug-in" cards. Are there any ways to distinguish between "on-board" PCI device and a PCI "plug-in" card. Thanks, Dhilip (2 Replies)
Discussion started by: diliphere
2 Replies
Login or Register to Ask a Question