#!/usr/bin/php
<?php

require __DIR__.'/base/block.php';

$iface = $argv[1] ?? 'eth0';
$inet = ($argv[2] ?? 'inet').' ';

$command = sprintf(
    'ip address show %s | grep %s | awk \'{ print $2 }\' | cut -d/ -f1',
    escapeshellarg($iface),
    escapeshellarg($inet)
);

$ip = trim(shell_exec($command));

if (empty($ip)) {
    die;
}

$fullText = pspan($iface, '#ccc', '#222').pspan($ip, '#ddd', '#000');

if (getenv('BLOCK_BUTTON') === '1') {
    shell_exec('export DISPLAY=:0; printf '.escapeshellarg($ip).' | xclip');
    shell_exec('export DISPLAY=:0; printf '.escapeshellarg($ip).' | xclip --selection clip');
}

echo block(
    'ip_'.$iface.'_'.trim($inet),
    [
        'full_text' => $fullText,
        'separator' => false,
        'separator_block_width' => 0,
    ]
);
Insérer
<div%key%id="gist-5c87a1065fa70-e21c1b4bf0cb442794468ed7aac15f2a7147f470" class="gist-container"></div>
<script src="https://gist.deblan.org/fr/embedjs/5c87a1065fa70?type=bash" async></script>