nerdbar.widget 项目使用教程

nerdbar.widget 项目使用教程

nerdbar.widgetÜbersicht system information bar for use with kwm window manager (or without).项目地址:https://gitcode.com/gh_mirrors/ne/nerdbar.widget

1. 项目的目录结构及介绍

nerdbar.widget 项目的目录结构如下:

nerdbar.widget/
├── README.md
├── bar.coffee
├── css
│   └── bar.css
├── scripts
│   ├── active-space.sh
│   ├── battery.sh
│   ├── cpu.sh
│   ├── focused-window.sh
│   ├── mem.sh
│   ├── now-playing.sh
│   ├── space.sh
│   └── time.sh
└── widgets
    ├── active-space.coffee
    ├── battery.coffee
    ├── cpu.coffee
    ├── focused-window.coffee
    ├── mem.coffee
    ├── now-playing.coffee
    ├── space.coffee
    └── time.coffee

目录介绍

  • README.md: 项目说明文件,包含项目的基本信息和使用方法。
  • bar.coffee: 主启动文件,负责加载和显示各个小部件。
  • css/: 存放样式文件的目录。
    • bar.css: 主样式文件,定义了小部件的外观和布局。
  • scripts/: 存放脚本的目录,这些脚本负责获取系统信息并传递给小部件。
    • active-space.sh: 获取当前活动空间信息。
    • battery.sh: 获取电池信息。
    • cpu.sh: 获取CPU使用信息。
    • focused-window.sh: 获取当前聚焦窗口信息。
    • mem.sh: 获取内存使用信息。
    • now-playing.sh: 获取当前播放的歌曲信息。
    • space.sh: 获取空间信息。
    • time.sh: 获取时间信息。
  • widgets/: 存放小部件的目录,这些小部件负责显示具体的信息。
    • active-space.coffee: 显示活动空间信息的小部件。
    • battery.coffee: 显示电池信息的小部件。
    • cpu.coffee: 显示CPU使用信息的小部件。
    • focused-window.coffee: 显示当前聚焦窗口信息的小部件。
    • mem.coffee: 显示内存使用信息的小部件。
    • now-playing.coffee: 显示当前播放歌曲信息的小部件。
    • space.coffee: 显示空间信息的小部件。
    • time.coffee: 显示时间信息的小部件。

2. 项目的启动文件介绍

项目的启动文件是 bar.coffee,它负责加载和显示各个小部件。以下是 bar.coffee 的主要内容:

# 导入必要的模块
os = require 'os'
fs = require 'fs'
path = require 'path'

# 定义小部件的路径
widgetPath = path.join __dirname, 'widgets'

# 加载所有小部件
fs.readdir widgetPath, (err, files) ->
    if err
        console.error "无法读取小部件目录: #{err}"
        return

    for file in files
        if file.endsWith '.coffee'
            require path.join widgetPath, file

启动文件介绍

  • bar.coffee 使用 Node.js 的 os, fs, 和 path 模块来处理文件和路径操作。
  • 它读取 widgets 目录下的所有 .coffee 文件,并加载这些文件作为小部件。

3. 项目的配置文件介绍

nerdbar.widget 项目的配置文件主要是 bar.coffee 和各个小部件的 .coffee 文件。以下是 bar.coffee 和一个小部件 battery.coffee 的配置示例:

bar.coffee 配置示例

# 定义小部件的显示位置和样式
widget.position = 'top'
widget.style = fs.readFileSync path.join(__dirname, 'css', 'bar.css'), 'utf-8'

battery.coffee 配置示例

# 定义电池小部件的显示内容和样式
widget.text = ->
    "#{scripts.battery.percentage}%"

widget.style = '''
    color: #fff;
    background: #333;
    padding: 5px;
'''

nerdbar.widgetÜbersicht system information bar for use with kwm window manager (or without).项目地址:https://gitcode.com/gh_mirrors/ne/nerdbar.widget

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
# -*- coding: UTF-8 -*- from lib2to3.pgen2 import driver from appium import webdriver from appium.webdriver.common.appiumby import AppiumBy el1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="通讯录") el1.click() el2 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ListView/android.widget.FrameLayout[3]/android.widget.RelativeLayout") el2.click() el3 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[1]/android.widget.TextView") el3.click() el4 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[8]") el4.click() el5 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[11]") el5.click()
06-08
根据你提供的代码,看起来你使用了 `lib2to3.pgen2.driver` 模块中的 `find_element` 方法。但是,`lib2to3.pgen2.driver` 模块实际上并没有这个方法,所以出现了 `AttributeError`。 我猜测你可能是想使用 Appium 的 `driver.find_element` 方法。如果是这样的话,你需要更改你的代码来正确导入 `appium.webdriver` 模块并使用它的 `driver` 属性。具体的修改如下: ```python # -*- coding: UTF-8 -*- from appium import webdriver from appium.webdriver.common.appiumby import AppiumBy # 创建 Appium driver desired_caps = {} desired_caps['platformName'] = 'Android' # 添加其他的 desired capabilities 选项... driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) # 执行测试操作 el1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="通讯录") el1.click() el2 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ListView/android.widget.FrameLayout[3]/android.widget.RelativeLayout") el2.click() el3 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[1]/android.widget.TextView") el3.click() el4 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[8]") el4.click() el5 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[11]") el5.click() # 关闭 driver driver.quit() ``` 注意,这里我使用了 `appium.webdriver` 模块的 `webdriver.Remote` 方法来创建 driver,然后使用 `driver.find_element` 方法来查找元素。最后,在测试结束后,我也关闭了 driver。你需要根据你的具体情况修改代码中的 `desired_caps` 和元素定位方式等内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

高慈鹃Faye

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值