我正在尝试为自己编写一个小函数来帮助我跟踪我正在做的事情,这个想法是在每个工作区中我都有不同的任务正在进行,并且每个工作区都有一个不同的“todo.txt”文件。我当然可以在调用命令时指定我在哪个工作区,但我真的很想自动检测哪个工作区并更改适当的文件。
有什么方法可以从命令行确定我在哪个工作区,以便我可以在 bash 函数中使用它?
xprop -root -notype _NET_CURRENT_DESKTOP
If you're using metacity and python you can do something like this:
python -c "import wnck; s=wnck.screen_get_default(); s.force_update(); w=s.get_active_workspace(); w_num=w.get_number(); print(w_num);" 2>/dev/null