diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..6e546c13 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +ROOT=$(realpath $(dirname $0)); + + +# Uninstall +sudo find /{usr,etc,var} -type d -name '*hotot*' -exec rm -fr {} \; +sudo find /{usr,etc,var} -type f -name '*hotot*' -exec rm -f {} \; + +rm -fr build && mkdir build && cd build + +cmake -DPYTHON_EXECUTABLE=/usr/bin/python2 -DWITH_GIR=off -DWITH_QT=off -DWITH_KDE=off -DWITH_CHROME=off -DWITH_GTK3=off -DWITH_GTK2=on -DWITH_GTK=off .. +make +sudo make install + +hotot diff --git a/data/js/lib.twitter.js b/data/js/lib.twitter.js index 82735b3a..3096cc18 100644 --- a/data/js/lib.twitter.js +++ b/data/js/lib.twitter.js @@ -893,10 +893,13 @@ function TwitterClient() { newText = interrupted_response + newText; interrupted_response = '' - var lines = newText.split(/[\n\r]/g); + var lines = newText.split(/[\n\r]/g), + ret for (var i = 0; i < lines.length; i += 1) { var line = lines[i].split(/({[^\0]+})/gm); for (var j = 0; j < line.length; j += 1) { + ret = null + if (!empty_tester.test(line[j])) { try { ret = JSON.parse(line[j]); @@ -911,7 +914,9 @@ function TwitterClient() { //return; } try { - callback(ret); + if(ret) { + callback(ret) + } } catch(e) { console.log('Streams callback: ' + e.message + '\n' + line); return; diff --git a/data/js/ui.main.js b/data/js/ui.main.js index 5316a8dc..ee9b68bd 100644 --- a/data/js/ui.main.js +++ b/data/js/ui.main.js @@ -165,6 +165,26 @@ function loadmore_messages(self, success, fail) { success); }, +getDisplayName: +function getDisplayName(user) { + const + displayName = '@' + user.screen_name, + + sanitize = function(text) { + return text.replace(/[^a-z0-9_]/i, '').toLowerCase() + } + + if(user.hasOwnProperty('name')) { + if(sanitize(user.name) === sanitize(user.screen_name)) { + return user.name + } + + return user.name + ' (' + displayName + ')' + } + + return displayName +}, + load_tweet_success: function load_tweet_success(self, json) { var ret = ui.Main.add_tweets(self, json, false); @@ -188,7 +208,8 @@ function load_tweet_success(self, json) { if (user.screen_name == globals.myself.screen_name) continue; text = json[i].text; - hotot_notify(user.screen_name, text, user.profile_image_url , 'content'); + + hotot_notify(ui.Main.getDisplayName(user), text, user.profile_image_url , 'content'); notify_count += 1; } if (3 < notify_count) { diff --git a/data/js/ui.template.js b/data/js/ui.template.js index f04cc347..22736e52 100644 --- a/data/js/ui.template.js +++ b/data/js/ui.template.js @@ -44,7 +44,7 @@ tweet_t:
\
\ \ - {%SCREEN_NAME%}\ + {%DISPLAY_NAME%}\ \
\
{%TEXT%}
\ @@ -150,7 +150,7 @@ message_t:
\ \ \ @@ -185,7 +185,7 @@ search_t:
\ \
{%TEXT%}
\ @@ -219,7 +219,7 @@ people_t:
\ \
{%DESCRIPTION%}
\ @@ -747,6 +747,7 @@ function form_dm(dm_obj, pagename) { m.ID = pagename + '-' + dm_obj.id_str; m.TWEET_ID = dm_obj.id_str; m.SCREEN_NAME = dm_obj.sender.screen_name; + m.DISPLAY_NAME = ui.Main.getDisplayName(dm_obj.sender) m.RECIPIENT_SCREEN_NAME = dm_obj.recipient.screen_name; m.USER_NAME = dm_obj.sender.name; m.DESCRIPTION = dm_obj.sender.description; @@ -870,7 +871,8 @@ function form_tweet (tweet_obj, pagename, in_thread) { m.RETWEET_ID = retweet_id; m.REPLY_ID = reply_id != null? reply_id:''; m.IN_THREAD = in_thread; - m.SCREEN_NAME = tweet_obj.user.screen_name; + m.SCREEN_NAME = tweet_obj.user.screen_name + m.DISPLAY_NAME = ui.Main.getDisplayName(tweet_obj.user) m.REPLY_NAME = reply_id != null? reply_name: ''; m.USER_NAME = tweet_obj.user.name; m.DESCRIPTION = tweet_obj.user.description; @@ -1037,6 +1039,7 @@ function form_search(tweet_obj, pagename) { m.ID = pagename + '-' + id; m.TWEET_ID = id; m.SCREEN_NAME = tweet_obj.from_user; + m.DISPLAY_NAME = ui.Main.getDisplayName({ 'screen_name': tweet_obj.from_user, 'name': tweet_obj.from_user_name }) m.USER_NAME = tweet_obj.from_user_name; m.PROFILE_IMG = tweet_obj.profile_image_url; m.TEXT = text; @@ -1058,6 +1061,7 @@ function form_people(user_obj, pagename) { var m = ui.Template.people_m; m.USER_ID = pagename + '-' + user_obj.id_str; m.SCREEN_NAME = user_obj.screen_name; + m.DISPLAY_NAME = ui.Main.getDisplayName(user_obj) m.USER_NAME = user_obj.name; m.DESCRIPTION = user_obj.description; m.PROFILE_IMG = user_obj.profile_image_url; diff --git a/hotot-gir/agent.py b/hotot-gir/agent.py index 5b59d88a..701e1bf6 100644 --- a/hotot-gir/agent.py +++ b/hotot-gir/agent.py @@ -158,6 +158,9 @@ def set_style_scheme(): ''' % str(bg[Gtk.StateType.NORMAL])); def get_prefs(name): + if name not in config.settings: + return '' + return config.settings[name] def set_prefs(name, value): diff --git a/hotot/agent.py b/hotot/agent.py index b125109b..fe584dc6 100644 --- a/hotot/agent.py +++ b/hotot/agent.py @@ -26,7 +26,7 @@ ## Disable GtkNotification on Gnome3 screen = gtk.gdk.screen_get_default() window_manager_name = screen.get_window_manager_name().lower() if screen else '' -if 'mutter' in window_manager_name: +if 'mutter' in window_manager_name or 'i3' in window_manager_name: USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM = False if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM: @@ -63,16 +63,16 @@ def init_notify(): notify.set_icon_from_pixbuf( gtk.gdk.pixbuf_new_from_file( utils.get_ui_object(os.path.join('image','ic64_hotot.png')))) - notify.set_timeout(5000) + notify.set_timeout(30000) def do_notify(summary, body, icon_file = None): if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM: return notify.do_notify(summary, body, icon_file) - n = pynotify.Notification(summary, body) if (icon_file == None or not os.path.isfile(icon_file) or os.path.getsize(icon_file) == 0): icon_file = utils.get_ui_object(os.path.join('image','ic64_hotot.png')); - n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file)) - n.set_timeout(5000) + n = pynotify.Notification(summary, body, 'file://' + icon_file) + #n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file)) + n.set_timeout(30000) n.show() def crack_hotot(uri): @@ -203,6 +203,9 @@ def set_style_scheme(): ''' % str(bg[gtk.STATE_NORMAL])); def get_prefs(name): + if name not in config.settings: + return '' + return config.settings[name] def set_prefs(name, value):