dwmblock 如何根据 $BUTTON 更新其输出?

问题描述 投票:0回答:0

我有一个简单的 bash 脚本

myscript.sh

#!/usr/bin/bash

clicked="none"

case $BUTTON in
    1) notify-send hello; clicked="left";;
    3) notify-send goodbye; clicked="right";;
esac

printf $clicked

我在

dwmblocks/blocks.h
中有这个:

//Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = {
    /*Icon*/    /*Command*/     /*Update Interval*/ /*Update Signal*/
    { "my script: ", "myscript.sh", 0, 12},
};

//sets delimeter between status commands. NULL character ('\0') means no delimeter.
static char delim[] = " | ";
static unsigned int delimLen = 5;

这在

dwm/config.h

static const Button buttons[] = {
//  ...
    { ClkStatusText,        0,              Button1,        sigdwmblocks,   {.i = 1} },
    { ClkStatusText,        0,              Button2,        sigdwmblocks,   {.i = 2} },
    { ClkStatusText,        0,              Button3,        sigdwmblocks,   {.i = 3} },
// ...

我想要的是该块首先显示“我的脚本:无”,每次我左键单击它时我希望它显示“我的脚本:左”和“我的脚本:右”每次我右键单击它。

当前的行为是,当我左键单击该块时,

notify-send
起作用并且我收到一条通知说“你好”,当我右键单击它时我收到一条通知说“再见”,但是
$clicked
变量由于某种原因保持不变,即使我在调用
notify-send
后更新它的值,它也不会改变。

我错过了什么?

statusbar x-dwm
© www.soinside.com 2019 - 2024. All rights reserved.