Pages

Saturday, September 28, 2024

Fedora 42 : ima: Error Communicating to TPM chip ... cannot be fixed.

I found this error and I tried to fix on my laptop HP 6710b:
[mythcat@fedora ~]$ sudo dmesg | grep Error
[    1.274790] tpm tpm0: [Hardware Error]: Adjusting reported timeouts: A 750->750000us B 2000->2000000us C 750->750000us D 750->750000us
[    2.240276] ima: Error Communicating to TPM chip
[    2.243913] ima: Error Communicating to TPM chip
[    2.246923] ima: Error Communicating to TPM chip
[    2.249919] ima: Error Communicating to TPM chip
[    2.253088] ima: Error Communicating to TPM chip
[    2.255923] ima: Error Communicating to TPM chip
[    2.258921] ima: Error Communicating to TPM chip
[    2.261938] ima: Error Communicating to TPM chip
[    2.415255] RAS: Correctable Errors collector initia
I update and nistall with the dnf5 tool
[root@fedora mythcat]# dnf5 upgrade 
...
[root@fedora mythcat]# dnf install tpm-tools
...
I reboot the Fedora and I try to test it:
[mythcat@fedora ~]$ lsmod | grep tpm
tpm_infineon           20480  0
To see all commands, use:
[mythcat@fedora ~]$ tpm_
tpm_changeownerauth  tpm_nvwrite          tpm_setclearable
tpm_clear            tpm_resetdalock      tpm_setenable
tpm_createek         tpm_restrictpubek    tpm_setoperatorauth
tpm_getpubek         tpm_restrictsrk      tpm_setownable
tpm_nvdefine         tpm_revokeek         tpm_setpresence
tpm_nvinfo           tpm_sealdata         tpm_takeownership
tpm_nvread           tpm_selftest         tpm_unsealdata
tpm_nvrelease        tpm_setactive        tpm_version
[root@fedora mythcat]#  dnf install tcsd
...
[root@fedora mythcat]# systemctl daemon-reload
[root@fedora mythcat]# systemctl start tcsd
[root@fedora mythcat]#  systemctl status tcsd

Fedora 42 : Fedora game project with pygame and agentpy - part 003.

I have upgraded the source code with the following changes:
  • added agent with logic using the python agentpy module;
  • I increased the grid to 16 x 16;
  • I kept the win condition at 8 pieces aligned in any direction;
  • I added conditions for displaying the equality message;
The game is hard to win, you can try on my pagure account.

Wednesday, September 25, 2024

Fedora 42 : Fedora game project with pygame and agentpy - part 002.

... and update from 8 in 8 with SVG file type.
The source code I used or you can find it on the pagure project:
import pygame
from pygame.math import Vector2
import random
import os 
username = os.getlogin()
# Initialize Pygame
pygame.init()
# Set up the display
width, height = 800, 800
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Eight-in-a-Row")
# Font setup
font = pygame.font.Font(None, 74)
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (0, 0, 120)
# Game board dimensions
BOARD_WIDTH = 8
BOARD_HEIGHT = 8

class Player:
    def __init__(self, color, is_computer=False):
        self.color = color
        self.pieces = set()
        self.is_computer = is_computer
        self.svg_image = self.load_svg_image()

    def add_piece(self, x, y):
        self.pieces.add((x, y))

    # def draw_pieces(self):
    #     for x, y in self.pieces:
    #         pygame.draw.circle(screen, self.color, 
    #                            (x * width // BOARD_WIDTH + width // (2 * BOARD_WIDTH), 
    #                             y * height // BOARD_HEIGHT + height // (2 * BOARD_HEIGHT)), 
    #                            min(width, height) // (2 * BOARD_WIDTH) - 5)
    
    def load_svg_image(self):
        if self.color == BLUE:
            svg_path = "penguin-svgrepo-com.svg"
        elif self.color == WHITE:
            svg_path = "cube-svgrepo-com.svg"
        else:
            svg_path = "cube-svgrepo-com.svg"
        return pygame.image.load(svg_path)

    def draw_pieces(self):
        piece_size = min(width, height) // (BOARD_WIDTH) - 10
        for x, y in self.pieces:
            pos = Vector2(x * width // BOARD_WIDTH + width // (2 * BOARD_WIDTH),
                          y * height // BOARD_HEIGHT + height // (2 * BOARD_HEIGHT))
            scaled_image = pygame.transform.scale(self.svg_image, (piece_size, piece_size))
            image_rect = scaled_image.get_rect(center=pos)
            screen.blit(scaled_image, image_rect)

    def make_move(self, board):
        if self.is_computer:
            empty_squares = [(x, y) for x in range(BOARD_WIDTH) for y in range(BOARD_HEIGHT) 
                             if (x, y) not in board[0] and (x, y) not in board[1]]
            if empty_squares:
                return random.choice(empty_squares)
        return None

def check_winner(player):
    directions = [(0, 1), (1, 0), (1, 1), (1, -1)]
    for x, y in player.pieces:
        for dx, dy in directions:
            if all((x + i*dx, y + i*dy) in player.pieces for i in range(8)):
                return True
    return False
    
def display_winner(winner):
    text = font.render(f"Player {winner} wins!", True, [145,190,190])
    text_rect = text.get_rect(center=(width // 2, height // 2))
    screen.blit(text, text_rect)
    pygame.display.flip()
    pygame.time.wait(3000)  # Display the message for 3 seconds

# Create players
player1 = Player(BLUE)
player2 = Player(WHITE, is_computer=True)
# Game loop
running = True
turn = 0
game_over = False

while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.MOUSEBUTTONDOWN and not game_over:
            if turn % 2 == 0:  # Human player's turn
                mouse_x, mouse_y = event.pos
                column = mouse_x // (width // BOARD_WIDTH)
                row = mouse_y // (height // BOARD_HEIGHT)
                
                if (column, row) not in player1.pieces and (column, row) not in player2.pieces:
                    player1.add_piece(column, row)
                    
                    if check_winner(player1):
                        # print("Player 1 wins!")
                        display_winner(username)
                        game_over = True
                    
                    turn += 1

    if not game_over and turn % 2 == 1:  # Computer player's turn
        move = player2.make_move((player1.pieces, player2.pieces))
        if move:
            player2.add_piece(*move)
            
            if check_winner(player2):
                # print("Player 2 (Computer) wins!")
                display_winner("Computer")
                game_over = True
            turn += 1

    screen.fill(BLACK)
    
    # Draw game board
    for i in range(BOARD_WIDTH + 1):
        pygame.draw.line(screen, WHITE, (i * width // BOARD_WIDTH, 0), (i * width // BOARD_WIDTH, height), 2)
    for i in range(BOARD_HEIGHT + 1):
        pygame.draw.line(screen, WHITE, (0, i * height // BOARD_HEIGHT), (width, i * height // BOARD_HEIGHT), 2)

    # Draw pieces
    player1.draw_pieces()
    player2.draw_pieces()
    pygame.display.flip()

pygame.quit()

Saturday, September 21, 2024

Fedora 42 : Fedora game project with pygame and agentpy - part 001.

I started a game project with the python packages pygame and agentpy in the Fedora 42 Linux distribution.
I used this version of Fedora:
[mythcat@fedora fedora_game]$ uname -a
Linux fedora 6.11.0-63.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Sep 15 17:14:12 UTC 2024 x86_64 GNU/Linux
... and this python version:
Python 3.12.3 (main, Apr 17 2024, 00:00:00) [GCC 14.0.1 20240411 (Red Hat 14.0.1-0)] on linux
You can find it on my fedora pagure repo

Thursday, September 12, 2024

News : I updated to Fedora 42 .

Few days ago, I updated the Fedora to version 42 on HP Compaq 6710b laptop.
Almost over four thousand Fedora packages have been instaled and reviewed ...
See the result :
$ uname -a
Linux fedora 6.11.0-0.rc7.20240910gitbc83b4d1f086.57.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Sep 10 15:43:53 UTC 2024 x86_64 GNU/Linux

Monday, June 10, 2024

Fedora 41 : Install portmaster.

Portmaster is a free and open-source application firewall that does the heavy lifting for you. Restore privacy and take back control over all your computer's network activity.
First, download the RPM package from the official website.
Use the dnf5 tool and install it.
The last step is to open, after restart Fedora, see the result on my openbox environment:

Friday, June 7, 2024

Fedora 41 : solving conky default configuration in openbox environment.

I installed Conky on an openbox environment and found an error, it doesn't display upload and download from the network correctly.
I had to use the ifconfig command to see the network interface and then I had to modify the default file.
The default configuration file can be found and edited with any text editor:
[root@fedora mythcat]# nano /etc/conky/conky.conf
Here's how it looks functionally.
-- Conky, a system monitor https://github.com/brndnmtthws/conky
--
-- This configuration file is Lua code. You can write code in here, and it will
-- execute when Conky loads. You can use it to generate your own advanced
-- configurations.
--
-- Try this (remove the `--`):
--
--   print("Loading Conky config")
--
-- For more on Lua, see:
-- https://www.lua.org/pil/contents.html

conky.config = {
    alignment = 'top_left',
    background = false,
    border_width = 1,
    cpu_avg_samples = 2,
    default_color = 'white',
    default_outline_color = 'white',
    default_shade_color = 'white',
    double_buffer = true,
    draw_borders = false,
    draw_graph_borders = true,
    draw_outline = false,
    draw_shades = false,
    extra_newline = false,
    font = 'DejaVu Sans Mono:size=12',
    gap_x = 60,
    gap_y = 60,
    minimum_height = 5,
    minimum_width = 5,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_console = false,
    out_to_ncurses = false,
    out_to_stderr = false,
    out_to_x = true,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'desktop',
    show_graph_range = false,
    show_graph_scale = false,
    stippled_borders = 0,
    update_interval = 1.0,
    uppercase = false,
    use_spacer = 'none',
    use_xft = true,
}

conky.text = [[
${color grey}Info:$color ${scroll 32 Conky $conky_version - $sysname $nodename $kernel $machine}
$hr
${color grey}Uptime:$color $uptime
${color grey}Frequency (in MHz):$color $freq
${color grey}Frequency (in GHz):$color $freq_g
${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}
${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}
${color grey}CPU Usage:$color $cpu% ${cpubar 4}
${color grey}Processes:$color $processes  ${color grey}Running:$color $running_processes
$hr
${color grey}File systems:
 / $color${fs_used /}/${fs_size /} ${fs_bar 6 /}
${color cyan}Networking:
${color grey}Up: ${upspeed ens1} ${color grey} - Down: ${downspeed ens1}

$hr
${color grey}Name              PID     CPU%   MEM%
${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
]]