hyprlock icon indicating copy to clipboard operation
hyprlock copied to clipboard

hide element

Open DIMFLIX opened this issue 7 months ago • 4 comments

Good afternoon, I have a question. I apologize if it has already been asked. I looked up the history of issue, but I couldn't find anything like this.

Is there any way to hide blocks based on the output of the command. Conditionally I have a certain command that will produce a 0 or 1 when executed. If 0, for example, then the block will be hidden.

From practical examples:

###########################################################
##==> Переменные
###########################################################
$wallpaper = $HOME/.config/meowrch/current_wallpaper
$avatar = /home/dimflix/.face.icon
$music-art-path = /tmp/meowrch-mpris.png
$network-sh = $HOME/bin/rofi-menus/network-manager.sh
$battery-sh = $HOME/bin/battery.sh
$layout-sh = $HOME/bin/kb-layout.sh
$music-sh = $HOME/bin/playerctlock.sh

###########################################################
##==> Основа
###########################################################
general {
    hide_cursor = true
    immediate_render = true
}

background {
    monitor =
    path = $wallpaper
    color = rgba(25, 20, 20, 1.0)
    blur_enabled = 1
    blur_passes = 3
}


###########################################################
##==> Иконки в правом верхнем углу
###########################################################
label {
  monitor =
  text = cmd[update:1000] echo "<span>$(sh $network-sh --status)</span>"
  color = rgba(242, 243, 244, 0.75)
  font_size = 15
  font_family = SF Pro Display Bold
  position = -35, 512
  halign = right
  valign = center
}

label {
  monitor =
  text = cmd[update:1000] echo "<span>$(sh $battery-sh --status --icon-only)</span>"
  color = rgba(242, 243, 244, 0.75)
  font_size = 15
  font_family = SF Pro Display Bold
  position = -75, 512
  halign = right
  valign = center
}

label {
  monitor =
  text = cmd[update:1000] echo "<span>$(sh $layout-sh)</span>"
  color = rgba(242, 243, 244, 0.75)
  font_size = 15
  font_family = SF Pro Display Bold
  position = -110, 512
  halign = right
  valign = center
}



###########################################################
##==> Время вверху поцентру
###########################################################
label {
  monitor =
  text = cmd[update:1000] echo "$(date +"%A, %B %d")"
  color = rgba(242, 243, 244, 0.75)
  font_size = 20
  font_family = SF Pro Display Bold
  position = 0, 405
  halign = center
  valign = center
}

label {
  monitor = 
  text = cmd[update:1000] echo "$(date +"%k:%M")"
  color = rgba(242, 243, 244, 0.75)
  font_size = 93
  font_family = SF Pro Display Bold
  position = 0, 310
  halign = center
  valign = center
}



###########################################################
##==> Блок пользователя и ввода пароля
###########################################################

# Основной контейнер
shape {
    monitor =
    size = 320, 280
    color = rgba(0, 0, 0, 0.3)
    rounding = 30
    border_size = 1
    border_color = rgba(255, 255, 255, 0.1)
    position = 0, 0
    halign = center
    valign = center
}

# Блок для аватарки
shape {
    monitor =
    size = 110, 110
    color = rgba(0, 0, 0, 0.4)
    rounding = -1
    border_size = 1
    border_color = rgba(255, 255, 255, 0.15)
    position = 0, 70
    halign = center
    valign = center
    zindex = 1
}

# Аватарка
image {
    monitor =
    path = $avatar
    size = 100
    rounding = -1
    border_size = 2
    border_color = rgba(255, 255, 255, 0.2)
    position = 0, 70
    halign = center
    valign = center
    zindex = 2
}

# Никнейм
label {
    monitor =
    text = cmd[update:1000] echo "$USER"
    color = rgba(255, 255, 255, 0.95)
    font_size = 16
    font_family = SF Pro Display Bold
    position = 0, -40
    halign = center
    valign = center
}

# Подсказка
label {
    monitor =
    text = Enter your password
    color = rgba(255, 255, 255, 0.8)
    font_size = 12
    font_family = SF Pro Display
    position = 0, -65
    halign = center
    valign = center
}

# Поле 
input-field {
    monitor =
    size = 240, 45
    outline_thickness = 0
    dots_size = 0.2
    dots_spacing = 0.15
    dots_center = true
    outer_color = rgba(0, 0, 0, 0.25)
    inner_color = rgba(0, 0, 0, 0.25)
    font_color = rgba(255, 255, 255, 0.9)
    fade_on_empty = false
    placeholder_text = <i>󰌾 Type to unlock...</i>
    hide_input = false
    check_color = rgba(204, 136, 34, 0.25)
    capslock_color = rgba(0, 0, 0, 0.25)
    numlock_color = -1
    bothlock_color = -1
    position = 0, -110
    halign = center
    valign = center
}


###########################################################
##==> Информация проигрываемой музыке
###########################################################
shape {
    monitor =
    size = 440, 110
    color = rgba(0 ,0 ,0,0.5)
    rounding = 20
    rotate = 0
    position = 0, -410
    halign = center
    valign = center
    zindex = 1
}

image {
    monitor =
    path = $music-art-path
    size = 80
    rounding = 5
    rotate = 0
    reload_time = 1
    reload_cmd = if [ ! -f $music-art-path ]; then cp $HOME/.config/hypr/skeleton.png $music-art-path; fi
    position = -160, -410
    halign = center
    valign = center
    zindex = 5
}

# PLAYER TITLE
label {
    monitor =
    text = cmd[update:1000] $music-sh --enable-skeleton --title
    color = rgba(255, 255, 255, 0.8)
    font_size = 12
    font_family = JetBrains Mono Nerd Font Mono ExtraBold
    position = 850, -410
    halign = left
    valign = center
    zindex = 5
}

# PLAYER LENGTH
label {
    monitor =
    text = cmd[update:1000] $music-sh --enable-skeleton --length
    color = rgba(255, 255, 255, 1)
    font_size = 11
    font_family = JetBrains Mono Nerd Font Mono
    position = -760, -432
    halign = right
    valign = center
    zindex = 5
}

# PLAYER STATUS
label {
    monitor =
    text = cmd[update:1000] $music-sh --enable-skeleton --status
    color = rgba(255, 255, 255, 1)
    font_size = 14
    font_family = JetBrains Mono Nerd Font Mono 
    position = -760, -410
    halign = right
    valign = center
    zindex = 5
}

# PLAYER SOURCE
label {
    monitor =
    text = cmd[update:1000] $music-sh --enable-skeleton --source
    color = rgba(255, 255, 255, 0.6)
    font_size = 10
    font_family = JetBrains Mono Nerd Font Mono 
    position = 850, -380
    halign = left
    valign = center
    zindex = 5
}

# PLAYER ARTIST
label {
    monitor =
    text = cmd[update:1000] $music-sh --enable-skeleton --artist
    color = rgba(255, 255, 255, 0.8)
    font_size = 10
    font_family = JetBrains Mono Nerd Font Mono ExtraBold
    position = 850, -430
    halign = left
    valign = center
    zindex = 5
}

I have this configuration. At the bottom you can see the elements responsible for displaying information about the music being played. So, I want to make it so that the block is not shown if no music is playing at the moment. Is it possible?

DIMFLIX avatar May 13 '25 11:05 DIMFLIX

Something explicit does not exist yet.

However, you can just return an empty string in case there is no music playing and that should work just fine. For example something like pidof mpv >/dev/null && echo "MUSIK PLAYING"

PointerDilemma avatar May 14 '25 05:05 PointerDilemma

Something explicit does not exist yet.

However, you can just return an empty string in case there is no music playing and that should work just fine. For example something like pidof mpv >/dev/null && echo "MUSIK PLAYING"

Yes, at the moment I'm returning a skeleton from the script. But it doesn't look very nice on the lock screen. I would like to see a function to hide blocks if the script sends some signal, or returns 1 or 0 I don't know how best to implement it

DIMFLIX avatar May 14 '25 05:05 DIMFLIX

Yes, at the moment I'm returning a skeleton from the script. But it doesn't look very nice on the lock screen. I would like to see a function to hide blocks if the script sends some signal, or returns 1 or 0 I don't know how best to implement it

OK, but what is the reason you can't return an empty string?

PointerDilemma avatar May 14 '25 06:05 PointerDilemma

Yes, at the moment I'm returning a skeleton from the script. But it doesn't look very nice on the lock screen. I would like to see a function to hide blocks if the script sends some signal, or returns 1 or 0 I don't know how best to implement it

OK, but what is the reason you can't return an empty string?

It's not going to be pretty)))) It would be much better if there was an option to dynamically show certain widgets

DIMFLIX avatar May 14 '25 06:05 DIMFLIX