Pages

Sunday, November 29, 2020

Fedora 33 : Testing xdotool linux tool .

Xdotool is a free and open source command line tool for simulating mouse clicks and keystrokes.
You can create beautiful scrips and tools with this command.
The help for this command is this:
[mythcat@desk ~]$ xdotool -help
Let's see some examples:
This simulate a keystroke for key c:
m[mythcat@desk ~]$ xdotool key c
c[mythcat@desk ~]$ c
The next command will simulate a key press for key c:
[mythcat@desk ~]$ xdotool keydown c
c[mythcat@desk ~]$ cccccccccccccccccccccccccccccccccccccccccccccccccccc^C
[mythcat@desk ~]$ ^C
The next command will simulate a key release for key c:
[mythcat@desk ~]$ xdotool keyup c
Use the enter key:
[mythcat@desk ~]$ xdotool key KP_Enter

[mythcat@desk ~]$
The next command will open a new tab in terminal:
[mythcat@desk ~]$ xdotool key shift+ctrl+t
This command simulate a right click at current location of pointer
xdotool click 3
The reference is: 1 – Left click, 2 – Middle click, 3 – Right click, 4 – Scroll wheel up, 5 – Scroll wheel down.
The next command get ID of terminal window currently in focus and then minimize it:
[mythcat@desk ~]$ xdotool getactivewindow windowminimize
This command lists all open windows:
[mythcat@desk ~]$ xdotool search --name ""
I get the open window with name New Tab - Google Chrome, with this command:
[mythcat@desk ~]$ xdotool search --name "New Tab -"
18874375
This command get the pid of the active window:
[mythcat@desk ~]$ xdotool getactivewindow getwindowpid
3538
The pid is from lxterminal tool:
[mythcat@desk ~]$ ps aux | grep 3538
mythcat     3538  0.3  0.4 601468 42500 ?        Sl   11:42   0:05 lxterminal
mythcat     5713  0.0  0.0 221432   780 pts/1    S+   12:07   0:00 grep 3538
The active window can be move with:
[mythcat@desk ~]$ xdotool getactivewindow windowmove 0 0
The next command get the current mouse coordinates:
[mythcat@desk ~]$ xdotool getmouselocation --shell
X=521
Y=339
SCREEN=0
WINDOW=16780805
These coordinates can be parsed:
[mythcat@desk ~]$ xdotool getmouselocation 2>/dev/null | cut -d\  -f1,2 -
x:0 y:0
[mythcat@desk ~]$ xdotool getmouselocation 2>/dev/null | sed 's/ sc.*//; s/.://g; s/ /x/'
0x0
Open inkscape and select Layer for this window Always on top:
[mythcat@desk ~]$ inkscape 
Start xdotool with focus on mouse and click on rectangle and draw area and follow the output:
[mythcat@desk ~]$ xdotool search --name "inkscape" behave %@ focus getmouselocation
x:25 y:239 screen:0 window:16786173
x:25 y:239 screen:0 window:16786173
x:340 y:378 screen:0 window:16786173
x:340 y:378 screen:0 window:16786173
x:332 y:358 screen:0 window:16786173
x:332 y:358 screen:0 window:16786173
x:518 y:643 screen:0 window:16786173
x:518 y:643 screen:0 window:16786173
x:723 y:466 screen:0 window:16780805
I create a bash script named inkscape_xdotool.sh and I add these commands:
#! /bin/sh
sleep 1
inkscape > /dev/null 2>&1 &
sleep 3
my_app=xdotool search --sync --name 'inkscape'
xdotool windowactivate $my_app
xdotool mousemove 0 0
xdotool mousemove 25 239
xdotool click 1
xdotool mousemove 332 358 mousedown 1 mousemove 518 643
xdotool mouseup 1
sleep 1
exit
I run the script:
[mythcat@desk ~]$ ./inkscape_xdotool.sh 
The script run well.
The output is an rectangle in inkscape with the default black color.

Saturday, November 28, 2020

Fedora 33 : Install and test with MonoGame .NET library .

MonoGame is a simple and powerful .NET library for creating games for desktop PCs, video game consoles, and mobile devices.
Today I tested with Fedora 33.
First let's install this templates for .NET Core CLI and the Rider IDE.:
[mythcat@desk ~]$ dotnet new --install MonoGame.Templates.CSharp

Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.109

----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
Getting ready...
  Restore completed in 2.76 sec for /home/mythcat/.templateengine/dotnetcli/v3.1.109/scratch/restore.csproj.
...
Install MGCB Editor is a tool for editing .mgcb files:
[mythcat@desk ~]$ dotnet tool install --global dotnet-mgcb-editor
You can invoke the tool using the following command: mgcb-editor
Tool 'dotnet-mgcb-editor' (version '3.8.0.1641') was successfully installed.
[mythcat@desk ~]$ mgcb-editor --register
Installing icon...
Installation complete!
Installing mimetype...
gtk-update-icon-cache: No theme index file.
Installation complete!
Installing application...
Installation complete!

Registered MGCB Editor!
Install C# extension for code editor:
[mythcat@desk ~]$ code --install-extension ms-dotnettools.csharp
Installing extensions...
Extension 'ms-dotnettools.csharp' is already installed.
The next step is to create new MonoGame projects:
[mythcat@desk ~]$ cd CSharpProjects/
[mythcat@desk CSharpProjects]$ dotnet new mgdesktopgl -o MyGame001
The template "MonoGame Cross-Platform Desktop Application (OpenGL)" was created successfully.

An update for template pack MonoGame.Templates.CSharp::3.8.0.1641 is available.
    install command: dotnet new -i MonoGame.Templates.CSharp::3.8.0.1641 
I run the default template and working well:
[mythcat@desk CSharpProjects]$ cd MyGame001
[mythcat@desk MyGame001]$ ls
app.manifest  Content  Game1.cs  Icon.bmp  Icon.ico  MyGame001.csproj  Program.cs
[mythcat@desk MyGame001]$ dotnet run Program.cs 
The default source code from Program.cs file is this:
using System;

namespace MyGame001
{
    public static class Program
    {
        [STAThread]
        static void Main()
        {
            using (var game = new Game1())
                game.Run();
        }
    }
} 

Tuesday, November 17, 2020

Fedora 33 : Smokeping tool.

Smokeping is a latency measurement tool. It sends test packets out to the net and measures the amount of time they need to travel from one place to the other and back. SmokePing consists of a daemon process which organized the latency measurements and a CGI which presents the graphs. 
You can install it like a webpage, see a demo on this webpage with Customers.SALAG.
[root@desk mythcat]# dnf search SmokePing
Last metadata expiration check: 0:12:18 ago on Tue 17 Nov 2020 08:45:57 PM EET.
=============================== Name Matched: SmokePing ===============================
smokeping.noarch : Latency Logging and Graphing System
[root@desk mythcat]# dnf install smokeping.noarch
Last metadata expiration check: 0:12:24 ago on Tue 17 Nov 2020 08:45:57 PM EET.
Dependencies resolved.
=======================================================================================
 Package                    Architecture  Version                  Repository     Size
=======================================================================================
Installing:
 smokeping                  noarch        2.7.3-2.fc33             fedora        564 k
Installing dependencies:
 fedora-logos-httpd         noarch        30.0.2-5.fc33            fedora         15 k
 fping                      x86_64        5.0-1.fc33               fedora         38 k
 httpd                      x86_64        2.4.46-1.fc33            fedora        1.4 M
 httpd-filesystem           noarch        2.4.46-1.fc33            fedora         14 k
 httpd-tools                x86_64        2.4.46-1.fc33            fedora         83 k
 libdbi                     x86_64        0.9.0-16.fc33            fedora         50 k
 mod_fcgid                  x86_64        2.3.9-21.fc33            fedora         77 k
 mod_http2                  x86_64        1.15.14-2.fc33           fedora        152 k
 perl-CGI                   noarch        4.50-4.fc33              fedora        198 k
 perl-CGI-Fast              noarch        2.15-6.fc33              fedora         18 k
 perl-Config-Grammar        noarch        1.13-6.fc33              fedora         29 k
 perl-FCGI                  x86_64        1:0.79-5.fc33            fedora         47 k
 perl-Net-DNS               noarch        1.21-5.fc33              fedora        356 k
 perl-Net-Telnet            noarch        3.04-15.fc33             fedora         62 k
 perl-Path-Tiny             noarch        0.114-3.fc33             fedora         67 k
 perl-SNMP_Session          noarch        1.13-25.fc33             fedora         67 k
 perl-Unicode-UTF8          x86_64        0.62-13.fc33             fedora         26 k
 rrdtool                    x86_64        1.7.2-14.fc33            fedora        569 k
 rrdtool-perl               x86_64        1.7.2-14.fc33            fedora         43 k

Transaction Summary
=======================================================================================
Install  20 Packages

Total download size: 3.8 M
Installed size: 11 M
Is this ok [y/N]: y
Downloading Packages:
...
Complete!
[root@desk mythcat]# dnf install lighttpd
...
Complete!

[root@desk mythcat]# dnf install lighttpd-fastcgi
...
Complete!
Most users use the smokeping service:
sudo service smokeping start
sudo service smokeping status
You can set your configuration file using this file:
[mythcat@desk ~]$ sudo vi /etc/smokeping/config
I let this file unchanged and I run these commands:
[mythcat@desk ~]$ sudo smokeping --check
Configuration file '/etc/smokeping/config' syntax OK.
[mythcat@desk ~]$ sudo smokeping --debug
### Compiling alert detector pattern 'someloss'
### >0%,*12*,>0%,*12*,>0%
...
Smokeping version 2.007003 successfully launched.
Not entering multiprocess mode with '--debug'. Use '--debug-daemon' for that.
FPing: probing 3 targets with step 300 s and offset 118 s.
FPing: Executing /usr/sbin/fping -C 20 -q -B1 -r1 -4 -i10 planet.fedoraproject.org fedoraproject.org 
docs.fedoraproject.org
FPing: Got fping output: 'planet.fedoraproject.org : 165 166 167 167 165 172 165 165 165 164 168 165 166 165
165 164 165 164 171 165'
FPing: Got fping output: 'fedoraproject.org        : 77.8 75.6 75.0 68.3 69.1 73.6 71.1 71.1 69.0 67.5
69.9 69.5 70.6 70.8 76.9 76.0 70.8 70.6 72.1 68.3'
FPing: Got fping output: 'docs.fedoraproject.org   : 171 165 165 165 180 164 170 164 164 165 163 171 
169 160 170 167 166 166 166 164'
Calling RRDs::update(/var/lib/smokeping/rrd/Ping/FedoraprojectOrg.rrd --template uptime:loss:median:
ping1:ping2:ping3:ping4:ping5:ping6:ping7:ping8:ping9:ping10:ping11:ping12:ping13:ping14:ping15:
ping16:ping17:ping18:ping19:ping20 1605642550:U:0:7.0800000000e-02:6.7500000000e-02:
...
1.6700000000e-01:1.6800000000e-01:1.7100000000e-01:1.7200000000e-01)

Saturday, November 7, 2020

Fedora 33 : Install PyGame 2.0 on Fedora.

Today I will show you how to install the python PyGame version 2.0 package with python version 3.9 in Fedora 33 distro. Let's install all Fedora packages need for this python package:
[root@desk pygame]# dnf install SDL2-devel.x86_64 
...
Installed:
  SDL2-devel-2.0.12-4.fc33.x86_64                                               

Complete!
[root@desk pygame]# dnf install SDL2_ttf-devel.x86_64
...
Installed:
  SDL2_ttf-2.0.15-6.fc33.x86_64       SDL2_ttf-devel-2.0.15-6.fc33.x86_64      

Complete!
[root@desk pygame]# dnf install SDL2_image-devel.x86_64
...
Installed:
  SDL2_image-2.0.5-5.fc33.x86_64      SDL2_image-devel-2.0.5-5.fc33.x86_64     

Complete!
[root@desk pygame]# dnf install SDL2_mixer-devel.x86_64 
...
Installed:
  SDL2_mixer-2.0.4-7.fc33.x86_64      SDL2_mixer-devel-2.0.4-7.fc33.x86_64     

Complete!
[root@desk pygame]# dnf install SDL2_gfx-devel.x86_64 
...
Installed:
  SDL2_gfx-1.0.4-3.fc33.x86_64        SDL2_gfx-devel-1.0.4-3.fc33.x86_64       

Complete!
[root@desk pygame]# dnf install portmidi-devel.x86_64 
...
Installed:
  portmidi-devel-217-38.fc33.x86_64                                             

Complete!
Use this command to clone it from GitHub and install it:
[mythcat@desk ~]$ git clone https://github.com/pygame/pygame
Cloning into 'pygame'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 38509 (delta 0), reused 0 (delta 0), pack-reused 38505
Receiving objects: 100% (38509/38509), 17.78 MiB | 11.66 MiB/s, done.
Resolving deltas: 100% (29718/29718), done.
[mythcat@desk ~]$ cd pygame/
[mythcat@desk pygame]$ python3.9 setup.py install --user


WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...


Hunting dependencies...
SDL     : found 2.0.12
FONT    : found
IMAGE   : found
MIXER   : found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
FREETYPE: found 23.4.17

If you get compiler errors during install, double-check
the compiler flags in the "Setup" file.
...
copying docs/pygame_tiny.gif -> build/bdist.linux-x86_64/egg/pygame/docs
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pygame.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
creating /home/mythcat/.local/lib/python3.9/site-packages/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
Extracting pygame-2.0.1.dev1-py3.9-linux-x86_64.egg to /home/mythcat/.local/lib/python3.9/site-packages
Adding pygame 2.0.1.dev1 to easy-install.pth file

Installed /home/mythcat/.local/lib/python3.9/site-packages/pygame-2.0.1.dev1-py3.9-linux-x86_64.egg
Processing dependencies for pygame==2.0.1.dev1
Finished processing dependencies for pygame==2.0.1.dev1
Let's test it:
[mythcat@desk pygame]$ ls
build	     dist  examples	    README.rst	setup.cfg  src_c   test
buildconfig  docs  pygame.egg-info  Setup	setup.py   src_py
[mythcat@desk pygame]$ python3.9
Python 3.9.0 (default, Oct  6 2020, 00:00:00) 
[GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 2.0.1.dev1 (SDL 2.0.12, python 3.9.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> 

Saturday, October 31, 2020

Fedora 33 : Upgrade from Fedora 32.

It is recommended to put SElinux in the disabled ... Use the following commands for this operation Edit the /etc/selinux/config file, run:
sudo vi /etc/selinux/config
Set SELINUX to disabled:
SELINUX=disabled
These commands will prepare the Fedora 32 for update
[root@desk mythcat]# dnf config-manager --set-disabled "*"
[root@desk mythcat]# dnf repolist 
[root@desk mythcat]# dnf config-manager --set-enabled updates
[root@desk mythcat]# dnf repolist 
repo id                                       repo name
fedora                                        Fedora 32 - x86_64
updates                                       Fedora 32 - x86_64 - Updates
[root@desk mythcat]# dnf upgrade --refresh
...
[root@desk mythcat]# dnf install dnf-plugin-system-upgrade
...
Let's upgrade with new Fedora 33 packages:
[root@desk mythcat]# dnf system-upgrade download --releasever=33 --allowerasing
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". 
Do you want to continue [y/N]: y
...
  file /usr/bin/ocamlprof.byte conflicts between attempted installs of ocaml-4.11.1-1.fc33.i686 
  and ocaml-4.11.1-1.fc33.x86_64
...
[root@desk mythcat]# dnf remove ocaml
...
I try again to update:
[root@desk mythcat]# dnf system-upgrade download --releasever=33 --allowerasing
...
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Complete!
Download complete! Use 'dnf system-upgrade reboot' to start the upgrade.
To remove cached metadata and transaction use 'dnf system-upgrade clean'
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
[root@desk mythcat]# dnf system-upgrade reboot
After reboot and system upgrade the new Fedora 33 is ready to use.
If exist another upgrade then use dnf tool command:
[sudo] password for mythcat: 
[root@desk mythcat]# dnf upgrade
Last metadata expiration check: 1:58:19 ago on Sat 31 Oct 2020 04:06:13 PM EET.
Dependencies resolved.
================================================================================
 Package                   Arch        Version               Repository    Size
================================================================================
Upgrading:
 dnf                       noarch      4.4.0-3.fc33          updates      445 k
 dnf-data                  noarch      4.4.0-3.fc33          updates       46 k
 libdnf                    x86_64      0.54.2-3.fc33         updates      604 k
 php-symfony-polyfill      noarch      1.19.0-1.fc33         updates       57 k
 python3-dnf               noarch      4.4.0-3.fc33          updates      410 k
 python3-hawkey            x86_64      0.54.2-3.fc33         updates      112 k
 python3-libdnf            x86_64      0.54.2-3.fc33         updates      775 k
 unixODBC                  x86_64      2.3.9-1.fc33          updates      460 k
 yum                       noarch      4.4.0-3.fc33          updates       43 k

Transaction Summary
================================================================================
Upgrade  9 Packages

Total download size: 2.9 M
Is this ok [y/N]: y
...
Upgraded:
  dnf-4.4.0-3.fc33.noarch             dnf-data-4.4.0-3.fc33.noarch             
  libdnf-0.54.2-3.fc33.x86_64         php-symfony-polyfill-1.19.0-1.fc33.noarch
  python3-dnf-4.4.0-3.fc33.noarch     python3-hawkey-0.54.2-3.fc33.x86_64      
  python3-libdnf-0.54.2-3.fc33.x86_64 unixODBC-2.3.9-1.fc33.x86_64             
  yum-4.4.0-3.fc33.noarch            

Complete!
[root@desk mythcat]# uname -a
Linux desk 5.8.16-300.fc33.x86_64 #1 SMP Mon Oct 19 13:18:33 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
A job very well done by Fedora team.

Thursday, October 22, 2020

Fedora 32 : Can be better? part 016.

Today I tested the Unity 3D version 2020 on Linux Fedora 32.
Maybe it would be better to integrate Unity 3D or Unity Hub in Fedora repo just like other useful software like Blender 3D, GIMP.
It will improve the user experience and attract new users and developers for this distro.
I download the AppImage from Unity website and I run with these commands:
[mythcat@desk Downloads]$ chmod a+x UnityHub.AppImage 
[mythcat@desk Downloads]$ ./UnityHub.AppImage 
r: 0
License accepted
...

Sunday, October 18, 2020

Fedora 32 : About positive and negative lookahead with Bash commands.

Today I will talk about something more complex in Linux commands called: positive and negative lookahead.
This solution can be found in several programming languages including Bash
The lookahead process is part of regular expressions.
The lookahead process looks ahead in the string and sees if it matches the given pattern, but then disregard it and move on.
It is very useful when we want to go through the strings.
The lookahead process can be both positive and negative depending on the purpose.
Negative lookahead is indispensable if you want to match something not followed by something else and looks like this:
q(?!s).
The string is the question q is analyzed and if it does not match and is not followed by s returns the result.
The positive lookahead it works the same way only now it is parsed if it corresponds to s.
The positive lookahead looks like this:
q(?=s)
Let's look at a simple example of detecting the PAE option for the processor.
We can use this command but we will find a lot of information ...
[root@desk mythcat]# cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Celeron(R) CPU G1620 @ 2.70GHz
stepping	: 9
...
In some cases, the resulting information can be taken using pipe and grep but they will be increasingly fragmented.
I will use the same command cpuinfo and we will look for the pae information in the flags.
All CPU flags can be found here.
Let's prove with internal lookahead to find the pae flag.
[root@desk mythcat]# cat /proc/cpuinfo | grep -oP '(?='pae')...' 
pae
pae
This result gives me additional information, namely that there are two cores.
Do you have a question?