Online video hd

Смотреть 365 видео

Официальный сайт ejnews 24/7/365

Смотреть видео бесплатно

17.12.10 02:47 nvbn

How-to`sПревращаем ноутбук в гирлянду!

Скрипт:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/python
# -*- coding: utf-8 -*-
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#      
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#      
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.


import time
import os

class Led:
  """Led class"""
 
  def __init__(self, type = 'file', **kwargs):
    """Init led and get status
   
    Keyword Arguments:
    type -- String
    adress -- String
    on -- String
    off -- String
   
    Returns: None
   
    """

    self.type = type
    if type == 'file':
      self.adress = kwargs['adress']
      file = open(self.adress, 'r')
      self.status = int(file.read())
      file.close()
    elif type == 'command':
      for arg in kwargs:
        setattr(self, arg, kwargs[arg])
        self.status = 0
 
  def push(self, data):
    """Change led file value
   
    Keyword Arguments:
    data -- Int
   
    Returns: None
   
    """

    file = open(self.adress, 'w')
    file.write(str(data))
    file.close()
   
  def action(self, type):
    """Run on/off command
   
    Keyword Arguments:
    type -- Int
   
    Returns: None
   
    """

    os.system(getattr(self, type and 'on' or 'off'))
 
  def change_status(self, value = -1):
    """Change led status"
   
    Keyword Arguments:
    value -- Int
   
    Returns: None
   
    """

    if value == -1:
      value = 1 - self.status
    if self.type == 'file':
      self.push(value)
    elif self.type == 'command':
      self.action(value)
    self.status = value

class Leds:
  """Flashing leds class"""
  leds = []
 
  def __init__(self, *args, **kwargs):
    """Init leds
   
    Keyword Arguments:
    *args -- Led init data
   
    Returns: None
   
    """

    try:
      self.interval = kwargs['interval']
    except NameError:
      pass
    for led in args:
      self.append(led)
     
  def append(self, adress):
    """Add led to leds array
   
    Keyword Arguments:
    adress -- String or Tuple
   
    Returns: None
   
    """

    if type(adress) == str:
      self.leds.append(Led(type='file', adress=adress))
    elif type(adress) == tuple:
      self.leds.append(Led(type='command', on=adress[0], off=adress[1]))
   
  def run(self):
    """Start led flashing"""
    while True:
      for led in self.leds:
        led.change_status()
        time.sleep(self.interval)
       
       
if __name__ == '__main__':
  leds = Leds(
              '/sys/devices/platform/asus_laptop/wlan',
              '/sys/devices/platform/asus_laptop/bluetooth',
              ('streamer -c /dev/video0 -b 16 -o /dev/null&', 'killall streamer'),
              interval=0.5,
              )
  leds.run()

Для работы на вашем ноутбуке нудно отредактировать 133-135 строки.
Можно указывать файл(пример - '/sys/devices/platform/asus_laptop/bluetooth') отвечающий за лампочку, либо команды для включения и выключения лампы:
('streamer -c /dev/video0 -b 16 -o /dev/null&', 'killall streamer'),

В файле настройки для ноутбуков asus, для web-камер команда универсальная (135 строчка).
Запускать через sudo, либо от рута.



idler 20.12.10 11:31 # +0
OFFTOP: а мой итак гирлянда. Одна постоянно мигающая лампочка HDD :)

Посты Комментарии
Последние посты
    Посты Комментарии
    Последние комментарии
      Посты Комментарии
      Изменения
        Посты Комментарии Изменения Черновики Избранное
        Черновики (все)
          Посты Комментарии Изменения Черновики Избранное
          Избранное (всё)
            Посты Комментарии Изменения Черновики Избранное
            Лучшие блоги (все 153)
            Топ пользователей Топ блогов
            Топ пользователей Топ блогов
            Элита (все 3080 из 227 городов)
            Топ пользователей Топ блогов

            Новенькие: sozinho, Whiter, Stixy90, slashdc, jpff
            welinux.ru

            Смотреть видео онлайн

            Онлайн видео бесплатно


            Смотреть русское с разговорами видео

            Online video HD

            Видео скачать на телефон

            Русские фильмы бесплатно

            Full HD video online

            Смотреть видео онлайн

            Смотреть HD видео бесплатно

            School смотреть онлайн