rszyma / kanata-tray

Tray Icon for Kanata
GNU General Public License v3.0
65 stars 1 forks source link

After layer change layer icon remains undetected #37

Closed qaxi closed 1 week ago

qaxi commented 1 week ago

Hello,

I am trying to set apropriate icons for layers. I found some dificulties to set icons by presets (see #36 ) so I try it in defaults. But it does not work. My default layout "homerow" is considered as "unknow" and therefor is using '*' = 'other.png' icon.

Part of my config:

...
[defaults.layer_icons]
qwertz = 'Ab.png'
qwertz_nomods = 'Ab.png'
homerow = 'HR.png'
hr = 'HR.png'
numeric = '12.png'
navigation = 'arrow.png'
mouse = 'mouse.png'
'*' = 'other.png'
...

When I run kanata-try-linux -log-level 1 I can see this

$ kanata-tray-linux -log-level 1
2024-11-12T14:46:14.528592137+01:00 INFO main.go:102 kanata-tray config folder: /home/klima/.config/kanata-tray
2024-11-12T14:46:14.529227634+01:00 DEBUG config.go:242 loaded config: &config.Config{
    PresetDefaults: config.Preset{
        Autorun:          false,
        KanataExecutable: "~/bin/kanata",
        KanataConfig:     "",
        TcpPort:          5829,
        LayerIcons:       {"*":"other.png", "homerow":"HR.png", "mouse":"mouse.png", "navigation":"arrow.png", "numeric":"12.png", "qwertz":"Ab.png", "qwertz_nomods":"Ab.png"},
        Hooks:            config.Hooks{
            PreStart: {
            },
            PostStart: {
            },
            PostStartAsync: {
            },
            PostStop: {
            },
        },
    },
    General: config.GeneralConfigOptions{},
    Presets: {
        "QTZ-homerow/numeric/arrows": &config.Preset{
          Autorun:          true,
          KanataExecutable: "~/bin/kanata",
          KanataConfig:     "~/.config/kanata/kanata.kbd",
          TcpPort:          5829,
          LayerIcons:       map[string]string{},
          Hooks:            config.Hooks{
            PreStart:       [][]string{},
            PostStart:      [][]string{},
            PostStartAsync: [][]string{},
            PostStop:       [][]string{},
          },
        }
        "QTZ-experimental": &config.Preset{
          Autorun:          false,
          KanataExecutable: "~/bin/kanata",
          KanataConfig:     "~/.config/kanata/experimental.kbd",
          TcpPort:          5829,
          LayerIcons:       map[string]string{},
          Hooks:            config.Hooks{
            PreStart:       [][]string{},
            PostStart:      [][]string{},
            PostStartAsync: [][]string{},
            PostStop:       [][]string{},
          },
        }
        "QTZ-sample cfg": &config.Preset{
          Autorun:          false,
          KanataExecutable: "~/bin/kanata",
          KanataConfig:     "~/.config/kanata/experimental.kbd",
          TcpPort:          5829,
          LayerIcons:       map[string]string{},
          Hooks:            config.Hooks{
            PreStart:       [][]string{},
            PostStart:      [][]string{},
            PostStartAsync: [][]string{},
            PostStop:       [][]string{},
          },
        }
    },
}
2024-11-12T14:46:14.529323341+01:00 WARN custom_icons.go:83 defaults - custom icon file can't be read: open /home/klima/.config/kanata-tray/icons/HR.png: no such file or directory
2024-11-12T14:46:14.570413466+01:00 INFO app.go:104 Running preset 'QTZ-homerow/numeric/arrows'
2024-11-12T14:46:14.570603379+01:00 INFO kanata.go:91 Running command: /home/klima/bin/kanata -c=/home/klima/.config/kanata/kanata.kbd --port 5829
2024-11-12T14:46:14.570876043+01:00 INFO kanata.go:99 Started kanata (pid=269864)
2024-11-12T14:46:17.07383234+01:00 INFO tcp_client.go:48 Connected to kanata via TCP (127.0.0.1:33006)
2024-11-12T14:46:17.074217272+01:00 DEBUG tcp_client.go:61 msg sent: {"RequestLayerNames":{}}
2024-11-12T14:46:17.074658138+01:00 DEBUG app.go:148 Received an event from kanata (preset=QTZ-homerow/numeric/arrows): tcp_client.ServerMessage{
  LayerChange: &tcp_client.LayerChange{
    NewLayer: "homerow",
  },
  LayerNames:       (*tcp_client.LayerNames)(nil),
  ConfigFileReload: (*tcp_client.ConfigFileReload)(nil),
}, 
2024-11-12T14:46:17.074728012+01:00 INFO custom_icons.go:48 Setting icon: preset:*, layer:*
2024-11-12T14:46:17.075099006+01:00 DEBUG app.go:148 Received an event from kanata (preset=QTZ-homerow/numeric/arrows): tcp_client.ServerMessage{
  LayerChange: (*tcp_client.LayerChange)(nil),
  LayerNames:  &tcp_client.LayerNames{
    Names: []string{
      "homerow",
      "navigation",
    },
  },
  ConfigFileReload: (*tcp_client.ConfigFileReload)(nil),
}, 
2024-11-12T14:46:17.075126684+01:00 WARN app.go:169 Layer 'qwertz_nomods' is mapped to an icon, but doesn't exist in the loaded kanata config
2024-11-12T14:46:17.07514345+01:00 WARN app.go:169 Layer 'numeric' is mapped to an icon, but doesn't exist in the loaded kanata config
2024-11-12T14:46:17.075174114+01:00 WARN app.go:169 Layer 'mouse' is mapped to an icon, but doesn't exist in the loaded kanata config
2024-11-12T14:46:17.075190023+01:00 WARN app.go:169 Layer 'qwertz' is mapped to an icon, but doesn't exist in the loaded kanata config
2024-11-12T14:46:31.997737623+01:00 DEBUG app.go:148 Received an event from kanata (preset=QTZ-homerow/numeric/arrows): tcp_client.ServerMessage{
  LayerChange: &tcp_client.LayerChange{
    NewLayer: "numeric",
  },
  LayerNames:       (*tcp_client.LayerNames)(nil),
  ConfigFileReload: (*tcp_client.ConfigFileReload)(nil),
}, 
2024-11-12T14:46:31.997908941+01:00 INFO custom_icons.go:38 Setting icon: preset:*, layer:numeric
2024-11-12T14:46:34.989582008+01:00 DEBUG app.go:148 Received an event from kanata (preset=QTZ-homerow/numeric/arrows): tcp_client.ServerMessage{
  LayerChange: &tcp_client.LayerChange{
    NewLayer: "homerow",
  },
  LayerNames:       (*tcp_client.LayerNames)(nil),
  ConfigFileReload: (*tcp_client.ConfigFileReload)(nil),
}, 
2024-11-12T14:46:34.989619427+01:00 INFO custom_icons.go:48 Setting icon: preset:*, layer:*
2024-11-12T14:49:51.157388856+01:00 DEBUG app.go:148 Received an event from kanata (preset=QTZ-homerow/numeric/arrows): tcp_client.ServerMessage{
  LayerChange: &tcp_client.LayerChange{
    NewLayer: "navigation",
  },
  LayerNames:       (*tcp_client.LayerNames)(nil),
  ConfigFileReload: (*tcp_client.ConfigFileReload)(nil),
}, 
2024-11-12T14:49:51.157417615+01:00 INFO custom_icons.go:38 Setting icon: preset:*, layer:navigation
2024-11-12T14:49:52.768264729+01:00 DEBUG app.go:148 Received an event from kanata (preset=QTZ-homerow/numeric/arrows): tcp_client.ServerMessage{
  LayerChange: &tcp_client.LayerChange{
    NewLayer: "homerow",
  },
  LayerNames:       (*tcp_client.LayerNames)(nil),
  ConfigFileReload: (*tcp_client.ConfigFileReload)(nil),
}, 
2024-11-12T14:49:52.768412592+01:00 INFO custom_icons.go:48 Setting icon: preset:*, layer:*

You can see that on startup and after layer change "homerow" layer does not get it's icon, but '*' ... It does not change when I change default layer name to for example "hr".

Other layouts get icon as expected.

rszyma commented 1 week ago

this line pretty much sums it up

2024-11-12T14:46:14.529323341+01:00 WARN custom_icons.go:83 defaults - custom icon file can't be read: open /home/klima/.config/kanata-tray/icons/HR.png: no such file or directory

does this file really exist?

qaxi commented 1 week ago

OMG ...

yes it is the reason ... missing file.

Sorry for opening this nonissue.