ironbar
ironbar copied to clipboard
[Question] about script and custom module?
I have recently migrated from Waybar to Ironbar, but I don't know how to convert this custom module:
Waybar module:
"custom/airpods": {
"format": " {} ",
"interval": 2,
"exec": "~/.config/scripts/airpod3.sh --status",
"on-click": "~/.config/scripts/airpod3.sh --toggle",
"tooltip": false
},
If I use the script module then I use something like this, but I cannot use the click command:
cmd = "~/.config/scripts/airpod3.sh --status"
If I use the custom module, I can use the click command, but I cannot execute the command for the status:
on_click = "!~/.config/scripts/airpod3.sh --toggle"
Does anybody know how to do this?
You should be able to use any of script, label or custom for this. The script module would be easiest. It does support on_click - if that's not working are you able to share the relevant config please and I can have a look?
The "--status" is working, but not "--toggle"
$airpod = {
name = "airpod"
type = "script"
mode = "watch"
interval = 2000
cmd = "~/.config/scripts/airpod3.sh --status"
on_click = "!~/.config/scripts/airpod3.sh --toggle"
}
If I run it manually it work.
$ ~/.config/scripts/airpod3.sh --toggle
Configuration
Config
let {
$tray = { type = "tray" }
$clock = {
type = "clock"
format = " %B %d %H:%M"
// format = "%d/%m/%Y %H:%M"
}
$focused = {
type = "focused"
show_icon = false
show_title = true
icon_size = 24
icon_theme = "Tela-circle-nord"
truncate.mode = "end"
truncate.max_length = 25
}
$music = {
type = "music"
player_type = "mpd"
format = "{title}/{artist}"
truncate = "end"
// truncate.length = 30
// truncate.max_length = 100
icons.play = " "
icons.pause = " "
icons.prev = ""
icons.next = ""
music_dir = "/home/bluebyt/Music"
}
$SysInfo = {
type = "sys_info"
interval.temps = 3
interval.disks = 300
interval.memory = 30
interval.cpu = 1
interval.networks = 3
format = [
" {cpu_percent}%"
" {memory_percent}%"
" {temp_c:coretemp-Package-id-0}°C"
" {disk_free:/}GB"
]
}
$cava = {
transition_type = "slide_end"
transition_duration = 750
name = "cava"
class = "cava"
type = "script"
cmd = "/home/bluebyt/.config/ironbar/scripts/cava"
mode = "watch"
}
$volume = {
type = "volume"
format = "{icon} {percentage}%"
max_volume = 100
icons.volume_high = ""
icons.volume_medium = ""
icons.volume_low = ""
icons.muted = ""
on_scroll_down = "wpctl set-volume @DEFAULT_SINK@ 2%-"
on_scroll_up = "wpctl set-volume @DEFAULT_SINK@ 2%+"
tooltip = "{{/home/bluebyt/.config/ironbar/scripts/volume}}%"
}
$workspace = {
type = "workspaces"
sort = "alphanumeric"
favorites = [ "1" "2" "3" ]
on_scroll_up = "hyprctl dispatch workspace e-1"
on_scroll_down = "hyprctl dispatch workspace e+1"
}
$wlogout = {
type = "custom"
bar = [
{
type = "button"
name = "wlogout"
class = "wlogout"
label = ""
on_click = "!~/.config/ironbar/scripts/wlogout"
}
]
}
$airpod = {
name = "airpod"
type = "script"
mode = "watch"
interval = 2000
cmd = "~/.config/scripts/airpod3.sh --status"
on_click = "!~/.config/scripts/airpod3.sh --toggle"
}
$work1 = {
type = "custom"
bar = [
{
type = "button"
name = "work1"
class = "work1"
label = "1"
on_click = "!~/.config/ipc-scripts/work1.py"
}
]
}
$work2 = {
type = "custom"
bar = [
{
type = "button"
name = "work2"
class = "work2"
label = "2"
on_click = "!~/.config/ipc-scripts/work2.py"
}
]
}
$work3 = {
type = "custom"
bar = [
{
type = "button"
name = "work3"
class = "work3"
label = "3"
on_click = "!~/.config/ipc-scripts/work3.py"
}
]
}
$work4 = {
type = "custom"
bar = [
{
type = "button"
name = "work4"
class = "work4"
label = "4"
on_click = "!~/.config/ipc-scripts/work4.py"
}
]
}
$work5 = {
type = "custom"
bar = [
{
type = "button"
name = "work5"
class = "work5"
label = "5"
on_click = "!~/.config/ipc-scripts/work5.py"
}
]
}
$work6 = {
type = "custom"
bar = [
{
type = "button"
name = "work6"
class = "work6"
label = "6"
on_click = "!~/.config/ipc-scripts/work6.py"
}
]
}
$pacman = {
type = "custom"
bar = [
{
type = "label"
name = "pacman"
class = "pacman"
label = " {{600000:checkupdates | wc -l}}"
}
]
}
$weather = {
name = "weather"
type = "script"
mode = "poll"
interval = 600000
cmd = "~/.config/ironbar/scripts/weather"
}
$clipboard = {
type = "clipboard"
max_items = 3
truncate.mode = "end"
truncate.length = 50
}
$start = [ $music $cava $focused ]
$center = [ $workspace ]
$end = [ $airpod $clipboard $volume $pacman $SysInfo $clock $wlogout ]
}
in {
icon_theme = "Tela-circle-nord"
position = "top"
start = $start
center = $center
end = $end
}
Styles
.container {
font-family: CaskaydiaCove Nerd Font;
/* font-weight: bold; */
font-size: 18px;
}
.cava {
padding: 0px 20px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 15px;
border-radius: 10px;
color:#7dcfff;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.background {
background-color: rgba(0, 0, 0, 0)
}
.wlogout {
padding: 0px 20px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 10px;
border-radius: 10px;
color:#ff757f;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.airpod {
padding: 0px 20px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 10px;
border-radius: 10px;
color:#ff757f;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
/* cpu */
.sysinfo .item:nth-child(1) {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 0px;
border-radius: 10px;
color:#ff9e64;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
/* memory */
.sysinfo .item:nth-child(2) {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 0px;
border-radius: 10px;
color:#7dcfff;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
/* temp */
.sysinfo .item:nth-child(3) {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 0px;
border-radius: 10px;
color:#bb9af7;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
/* disk */
.sysinfo .item:nth-child(4) {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 8px;
border-radius: 10px;
color:#9ece6a;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.pacman {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 10px;
margin-left: 5px;
border-radius: 10px;
color:#c3e88d;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.volume {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 7px;
margin-left: 3px;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
color:#9abdf5;
background:#1a1b26;
opacity: 0.8;
}
.popup-volume {
padding: 20px 20px 20px 20px;
border-radius: 5px;
color: #c0caf5;
/* background: #1a1b26; */
background-color: rgba(26,27,38,0.800);
border: 2px solid #c3e88d;
}
.clock {
font-family: CaskaydiaCove Nerd Font;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 10px;
padding-right: 20px;
padding-left: 20px;
padding-bottom: 3px;
border-radius: 10px;
color:#7dcfff;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.clock_date {
color: rgb(94,129,172);
}
.popup-clock {
font-weight: bolder;
background-color: rgba(26,27,38,0.800);
border-radius: 10px;
border: 2px solid #c3e88d;
}
.popup-clock .calendar-clock {
color: #c0caf5;
/* font-size: 2.5em; */
padding-bottom: 0.1em;
}
.popup-clock .calendar {
background-color: rgba(26,27,38,0.800);
color: #c0caf5;
border-radius: 10px
}
.popup-clock .calendar .header {
padding-top: 1em;
border-top: 1px solid #424242;
font-size: 1.5em;
}
.popup-clock .calendar:selected {
background-color: #3d59a1;
}
.focused {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 10px;
margin-left: 3px;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
color:#c3e88d;
background:#1a1b26;
opacity: 0.8;
/* top right bottom left */
}
.clipboard {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 7px;
margin-left: 3px;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
color:#9abdf5;
background:#1a1b26;
opacity: 0.8;
}
.popup-clipboard
{
margin-left: 5px;
padding: 10px 10px 10px 10px;
border-radius: 5px;
color: #c0caf5;
background: #1a1b26;
background-color: rgba(26,27,38,0.800);
border: 2px solid #c3e88d;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.work1,
.work2,
.work3 {
padding: 0px 5px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 3px;
border-radius: 10px;
background: #c3e88d;
color: #4c566a;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.script {
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 5px;
border-radius: 10px;
color:#9abdf5;
background:#1a1b26;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.music {
border-radius: 10px;
padding: 0px 10px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 7px;
margin-left: 10px;
color:#bb9af7;
background:#1a1b26;
opacity: 0.8;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.popup-music {
margin-left: 5px;
padding: 10px 10px 10px 10px;
border-radius: 5px;
color: #c0caf5;
background: #1a1b26;
background-color: rgba(26,27,38,0.800);
border: 2px solid #c3e88d;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.popup-music.volume {
}
.popup-music .volume .slider {
padding: 2px 2px 2px 2px;
margin-top: 5px;
margin-bottom: 5px;
margin-right: 5px;
margin-left: 5px;
}
.popup-music .volume .icon {
}
tooltip.background {
background-color: rgba(00, 00, 00, 0.5);
font-size: 18px;
border-radius: 10px;
color: #FDFDFD;
}
tooltip * {
padding: 4px;
background-color: transparent;
color: white;
}
.host tooltip {
background-color: rgba(255, 00, 00, 0.5);
}
.workspaces {
background: #1a1b26;
padding: 5px 5px;
margin-top: 5px;
margin-bottom: 15px;
margin-right: 10px;
margin-left: 10px;
border-radius: 10px;
font-weight: bold;
font-style: normal;
opacity: 0.8;
font-size: 16px;
color: #FFFFFF;
box-shadow: rgba(0, 0, 0, 0.288) 2px 2px 5px 2px;
}
.workspaces button {
padding: 1px 1px;
margin: 0px 1px;
border-radius: 19px;
border: 0px;
color: #c0caf5;
background-color: #3b4261;
transition: all 0.3s ease-in-out;
opacity: 0.7;
}
.workspaces .item.focused {
color: #FFFFFF;
background: #545c7e;
border-radius: 19px;
min-width: 50px;
transition: all 0.3s ease-in-out;
opacity:1.0;
}
.workspaces button:hover {
color: #FFFFFF;
background: #545c7e;
border-radius: 15px;
min-width: 50px;
opacity:0.7;
}
is the "!" in the on_click before the script intentional ? To get more information what is happing put some notify_send in the script and follow the steps in the notifications.
The symbol "!" is mandatory according to the wiki for the custom module.
I tried with "!" and without it and it doesn't work in both case.
Custom module
To execute shell commands, prefix them with an !. For example, if you want to run ~/.local/bin/my-script.sh on click, you'd set on_click to !~/.local/bin/my-script.sh.
well in mybar (:-) a custom module an image with a shell script does not work with ! and does work without !
this works:
$power ={
bar =[
{
src="icon:workspace-overview"
name = "popupbar"
type = "image"
size = 24
on_click_left = "ironbar bar side toggle-visible"
}
{
src="icon:help-keyboard-shortcuts"
name = "keyhelp"
type = "image"
size = 24
on_click_left = "~/.config/hypr/scripts/keybinds.sh"
}
] }
Finally I got some time to play with this! I used the script module to do this and its works!
$airpod = {
name = "airpod"
type = "script"
mode = "watch"
interval = 2000
cmd = "~/.config/scripts/airpod3.sh --status"
on_click_left = "~/.config/scripts/airpod3.sh --toggle"
}
Thanks for your help @JakeStanger and @bertSN1601