Xdotool offset/mismatch when using windowmove - bash

i am trying to place a window with xdotool.
Its not going where i want it to.
I tried the following code:
terminal=`xdotool getactivewindow`
xdotool getwindowgeometry $terminal
xdotool windowmove $terminal 0 0
xdotool getwindowgeometry $terminal
xdotool windowmove --relative $terminal -10 -10
xdotool getwindowgeometry $terminal
and got the following output:
Window 62914571
Position: 10,80 (screen: 0)
Geometry: 1694x1046
Window 62914571
Position: 10,62 (screen: 0)
Geometry: 1694x1046
Window 62914571
Position: 10,62 (screen: 0)
Geometry: 1694x1046
side notes:
i am using a laptop + one monitor connected via hdmi1 and i modified my /etc/lightdm/lightdm.conf to
[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
session-setup-script=/home/user/.monitor.sh
the .monitor.sh looks like that:
cvt 2560 1440 30
xrandr --newmode "2560x1440_30.00" 146.25 2560 2680 2944 3328 1440 1443 1448 1468 - hsync +vsync
xrandr --addmode HDMI1 "2560x1440_30.00"
any tipps or hints what could cause the problem?

Related

gnuplot frequency histogram in shell with only one column of information

I want to make gnuplot with shell, i have similar code to do the whork, but i need to use only 1 column of integers to make frequency histogram.
this code puts out histogram that shows x axis every line and y axis its value, but i want to make frequency histogram for e.g. every 10 on x axis
code:
#!/bin/sh
#launch make_graphs $input $output_histogram.png $output_scatterplot.png $output_stats.txt
input=$1
output_h=$2
output_s=$3
output_stats=$4
gnuplot -persist <<-EOFMarker
set terminal png transparent truecolor
set output "$output_h"
set style data histogram
set style histogram cluster gap 50.0
set style fill solid border -1
set border lc rgb "red"
set xtics textcolor rgb "red"
set ytics textcolor rgb "red"
set key textcolor rgb "red"
set xlabel "sizes"
set ylabel "frequencies"
set boxwidth 3.0
plot "$input" using 1:xtic(2) title "seqlen frequences" ######### I need to change this line
set output "$output_s"
set xlabel "sizes"
set ylabel "frequences"
plot "$input" smooth csplines title "seqlen frquences"
set print "$output_stats"
stats "$input"
stats "$input"
#print "mean: ", STATS_sumxy/STATS_sum
#print "standart deviation: ", STATS_stddev
EOFMarker
input file egzample
12
278
99
9
219
219
164
185
164
438
438
438
438
185
164
286
286
12
12
10
10
35
35
6
6
6

verifying where 'kworker/n:n' (in ps -aux) is invoked from

In the result of 'ps -aux', I couldn't find how to verify that 'kworker/...' are created from and what module/functions are related to it.
Please let me know how I find out kworkers are from with pid or else.
I've try to check files in /proc, nothing is shown about this.
$ ps -aux | grep kworker
root 15 0.0 0.0 0 0 ? S Aug12 0:00 [kworker/1:0]
root 16 0.0 0.0 0 0 ? S< Aug12 0:00 [kworker/1:0H]
root 85 0.0 0.0 0 0 ? S< Aug12 0:09 [kworker/0:1H]
root 3562 0.0 0.0 0 0 ? S< Aug12 0:00 [kworker/0:2H]
root 5578 0.0 0.0 0 0 ? S 11:13 0:01 [kworker/0:0]
root 5579 0.0 0.0 0 0 ? S 11:13 0:00 [kworker/u4:1]
root 8789 0.1 0.0 0 0 ? S 12:19 0:10 [kworker/0:2]
root 30236 0.0 0.0 0 0 ? S 08:39 0:01 [kworker/u4:0]
A good solution for these kinds of problems that I'm familiar with is to use the perf tool (It's not always enabled by default and you may need to install perf on your device).
Step 1: Set perf to record workqueue events:
perf record -e 'workqueue:*' -ag -T
Step 2: Run it as long as you think you need to catch the event (10 seconds should be ok if this event is frequent enough, but you can let it run longer, depending on the available free space you have left on your device) and then stop it with Ctrl + C.
Step 3: Print the captured events (on Linux versions < 4.1 I think it should be -f and not -F):
perf script -F comm,pid,tid,time,event,trace
This will display something like this: 
task-name pid/tid timestamp event
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
turtle   9201/9201 1473.339166:  workqueue:workqueue_queue_work: work struct=0xef20d4c4 function=pm_runtime_work workqueue=0xef1cb600 req_cpu=8 cpu=1
turtle   9201/9201 1473.339176: workqueue:workqueue_activate_work: work struct 0xef20d4c4
kworker/0:3  24223/24223 1473.339221: workqueue:workqueue_execute_start: work struct 0xef20d4c4: function pm_runtime_work
kworker/0:3  24223/24223 1473.339248:  workqueue:workqueue_execute_end: work struct 0xef20d4c4
Step 4: Analyzing the table above:
In the first row, a task named turtle (pid 9201) is pushing the work pm_runtime_work to the workqueue.
In the third row, we can see that the kworker/0:3 (pid 24223) is executing that work.
Summary: Now back to your questions, we see that kworker/0:3 has been requested by turtle task to run the pm_runtime_work function.
Now, if you want to dig further, you'll have step into the code and see what the pm_runtime_work function does. Good luck !!!

How do i get the Windows PPID of a procces running out of cygwin?

I need to kill a windows procces that were started by the programm called from cygwin.
Here's what I do:
${wccoaDirNix}/bin/WCCILpmon.exe -proj ${projName} -user root: &
This process creates other windows process:
$ ps -W
PID PPID PGID WINPID TTY UID STIME COMMAND
1960 1 1960 1960 ? 197609 19:21:57 /usr/bin/mintty
7316 0 0 7316 ? 0 19:21:57 C:\Windows\System32\conhost.exe
1700 1960 1700 1576 pty1 197609 19:21:57 /usr/bin/bash
I 10760 9840 10760 7560 pty0 197609 19:25:47 /usr/bin/bash
32 10760 10760 32 pty0 197609 19:26:28 /cygdrive/c/Siemens/Automation/WinCC_OA/3.14/bin/WCCILpmon
6264 0 0 6264 ? 0 19:26:28 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILpmon.exe
8420 0 0 8420 ? 0 19:26:29 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILdata.exe
6336 0 0 6336 ? 0 19:26:29 C:\Windows\System32\conhost.exe
2808 0 0 2808 ? 0 19:26:30 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILevent.exe
6784 0 0 6784 ? 0 19:26:30 C:\Windows\System32\conhost.exe
2972 0 0 2972 ? 0 19:26:30 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCOActrl.exe
11004 0 0 11004 ? 0 19:26:30 C:\Windows\System32\conhost.exe
9536 0 0 9536 ? 0 19:26:31 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILsim.exe
7372 0 0 7372 ? 0 19:26:31 C:\Windows\System32\conhost.exe
9128 0 0 9128 ? 0 19:26:31 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCOAui.exe
3964 0 0 3964 ? 0 19:27:48 C:\Siemens\Automation\WinCC_OA\3.14\bin\WCCILdatabg.exe
How can i kill them?
I tried to kill them by the following command:
ps -W | grep "WCC" | awk '{print $1}' | xargs kill -f;
But it does not work as it should, it kills all processes in which name there are letters WCС, and I need to terminate only the child processes of WCCILpmon.exe
I also read the question on cygwinlist about same problem
And it upset me, is there no way to realize it?
As you need to kill a NOT cygwin process, it is better to use
windows specific program.
One example is:
https://learn.microsoft.com/en-us/sysinternals/downloads/pskill

Trying to use PWM to control a servo on my BBB, servo not moving

When I try to use my servo with my BBB, using the following commands to try to move it, the servo doesn't move.
modprobe pwm_test
echo am33xx_pwm > /sys/devices/bone_capemgr.9/slots
echo bone_pwm_P9_14 > /sys/devices/bone_capemgr.9/slots
echo 500 > /sys/devices/ocp.2/pwm_test_P9_13.14/period
echo 250 > /sys/devices/ocp.2/pwm_test_P9_13.14/duty
echo 1 > /sys/devices/ocp.2/pwm_test_P9_13.14
I'm using the parallax continuous rotation servo (http://www.parallax.com/product/900-00008). I have the servo's out connected to the BBB's ground (pin 1 on the left header, if the ethernet port is on top), in connected to +3v (pin 3), and pwm connected to pin 14.
According to the datasheet of this servo, the minimum voltage for the power supply is 4V, so I would advise to try to connect the red wire (pin2) to the 5V supply source which is on pins 5 and 6 on the the header P9 on the BBB.
#elimirks: BBB stands for BeagleBone Black
I have this step working fine. I can control 2 servos from command line.
what I did for one servo:
echo am33xx_pwm > /sys/devices/bone_capemgr.9/slots
echo bone_pwm_P9_14 > /sys/devices/bone_capemgr.9/slots
echo 0 > /sys/devices/ocp.3/pwm_test_P9_14.15/run
echo 0 > /sys/devices/ocp.3/pwm_test_P9_14.15/polarity
echo 20000000 > /sys/devices/ocp.3/pwm_test_P9_14.15/period
echo 1500000 > /sys/devices/ocp.3/pwm_test_P9_14.15/duty
echo 1 > /sys/devices/ocp.3/pwm_test_P9_14.15/run
The servo moves with duty values from 1000000 to 2000000 with 1500000 being the center position.
I could enable a second servo with:
echo bone_pwm_P8_19 > /sys/devices/bone_capemgr.9/slots
btw. it seems that the provided device tree overlays do not allow to use multiple pwm outputs from one pwm chip (for example P9_14 and P9_16).

Why does there appear text on my command line even though I've redirected both STDOUT and STDERR to /dev/null?

I'm trying to unmount a encfs-filesystem from a script, but no matter how I try I seem unable to prevent the fuse error below to appear on screen/in crontab emails.
# exec 3>&1 1>/dev/null 4>&2 2>/dev/null; setsid fusermount -u /data/encfs; exec 1>&3 2>&4 3>&- 4>&-
# fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
The error itself I have to live with. The unmount is successfull and the error is false and due to a bug that is long gone in modern versions of fuse. I'm stuck with the older version since I'm on special hardware running a semi-ancient version of debian.
What annoys me is that I cannot tell the system to toss the nonsense message in /dev/null.
How does the message even appear on my screen after me using both setsid and redirects in my best efforts to prevent it?
EDIT:
# exec 3>&1 1>/dev/null 4>&2 2>/dev/null; setsid fusermount -u /data/encfs > /dev/null 2>&1; EXIT=$?; exec 1>&3 2>&4 3>&- 4>&-; echo $EXIT
0
# fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
I've even tried things like:
perl -e "`fusermount -u /data/encfs`"
But the error remain the same.
My /etc/syslog.conf:
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv,cron.none -/var/log/syslog
cron.* -/var/log/cron.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
*.=debug;\
auth,authpriv.none;\
mail.none -/var/log/debug
*.=info;*.=notice;*.=warn;\
auth,authpriv.none;\
cron,daemon.none;\
mail.none -/var/log/messages
EDIT2:
I don't think fusermount is the program actually generating the text. It pokes something else that does:
# strace -o ~/trash/strace.txt fusermount -u /data/encfs; EXIT=$?; echo $EXIT; grep write ~/trash/strace.txt
fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
0
write(5, "/dev/hdc1 / ext3 rw,noatime 0 0\n", 32) = 32
write(5, "proc /proc proc rw 0 0\n", 23) = 23
write(5, "devpts /dev/pts devpts rw 0 0\n", 30) = 30
write(5, "sysfs /sys sysfs rw 0 0\n", 24) = 24
write(5, "tmpfs /ramfs ramfs rw 0 0\n", 26) = 26
write(5, "tmpfs /USB tmpfs rw,size=16k 0 0"..., 33) = 33
write(5, "/dev/c/c /c ext3 rw,noatime,acl,"..., 65) = 65
write(5, "nfsd /proc/fs/nfsd nfsd rw 0 0\n", 31) = 31
write(5, "usbfs /proc/bus/usb usbfs rw 0 0"..., 33) = 33
write(5, "//localhost/smb /root/folder"..., 55) = 55
If I let strace log to stdout I get the error message in the middle of the umount system call:
# strace fusermount -u /data/encfs
execve("/usr/bin/fusermount", ["fusermount", "-u", "/data/encfs"], [/* 16 vars */]) = 0
[... abbreviating ...]
close(5) = 0
munmap(0x20020000, 16384) = 0
profil(0, 0, 0x2010c168, 0x4) = 0
umount("/data/encfs", 0fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
) = 0
profil(0, 0, 0x1177c, 0x20179f98) = 0
stat64("/etc/mtab", {st_mode=S_IFREG|0644, st_size=407, ...}) = 0
ftime(0x13840) = 0
Use strace on the command. It will show you details about what's going on, including the number of the descriptor to which the message is written
strace fsusermount -u /data/encfs
If the message comes from fsusermount you should see a line like
write(0, "- fuse kernel module not installed (modprobe fuse)\n")
somewhere in the output. The number (not necessarily 0) is the number of the file descriptor to which the message is written. Redirecting the descriptor with that number should get you rid of the message:
fsusermount -u /data/encfs 0>/dev/null
Figured it out.
The error message does not come from the fusermount, it comes from the mount command when fusermount runs.
Doing it like this fixes the problem:
# encfs --extpass=echo_key.sh /data/.encfs /data/encfs 2>/dev/null; sleep 3; fusermount -u /data/encfs
#
Feels so obvious now that I know...

Resources